Java code--date class get current time-formatted output
Source: Internet
Author: User
Package CN. Date;
Import Java.text.Format; Import Java.text.SimpleDateFormat; Import Java.util.Date;
/*
*dateformat is an abstract class of date/time format subclasses, because he is an abstract class, so there should be a concrete construction method *public class Simpledateformatextends Dateformatsimpledateformat * is a specific class that formats and parses dates in a way that is relevant to the locale
*public final string format (date date) formats a date as a day/time string. *simpledateformat () Displays the time *simpledateformat (String pattern) in the default mode to show the time in the given pattern
* The number of days in the month Month *d month of year *m years *y (*h) number 0-23 minutes *m seconds * * * * * public class *s Rmatdemo {
public static void main (string[] args) { //Create a Date object Date D=new date (); System.out.println (d ); /*//Create a Format object SimpleDateFormat sdf=new SimpleDateFormat (); System.out.priNtln (SDF); * * SimpleDateFormat sdf=new SimpleDateFormat ("Yyyy-mm-dd HH:mm:ss"); //format as Date/time string String Cc=sdf.format (d); System.out.println ( CC); } }
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service