Java code--date class gets the current time-formatted output

Source: Internet
Author: User

44:52Hits: 2299Package CN. Date;import Java.text.Format;import Java.text.SimpleDateFormat;import java.util.Date;/**dateformat is the abstract class for date/time formatting subclasses, because he is an abstract class, so there is a concrete way to construct*public class Simpledateformatextends Dateformatsimpledateformat* is a specific class for formatting and parsing dates in a language-related way*public Final string format (date date) formats one date as a date/time string. *simpledateformat () displays the time in the default mode*simpledateformat (String pattern) displays time in a given pattern **y Yearmonth of the year in *m*d number of days in month*h hours in the day (0-23) number*m min*s sec****/Public class Dateformatdemo {         Public static void Main (string[] args) {                                //Create a Date objectDate D=new date ();System.out.println (d);/*//Creating a formatted objectSimpleDateFormat sdf=new SimpleDateFormat ();System.out.println (SDF); */SimpleDateFormat sdf=new SimpleDateFormat ("Yyyy-mm-dd HH:mm:ss");//format as Date/time stringString Cc=sdf.format (d);System.out.println (cc);        }                        }

Java code--date class gets the current time-formatted output

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.