Java Date Class Summary

Source: Internet
Author: User

Import Java.text.*;import java.util.*;class Test2 {public static void main (string[] args) {System.out.println (       System.currenttimemillis ());//The method is to return the current computer time, the time expression format is the current computer time and GMT time (GMT) January 1, 1970 0:0 0 seconds the number of milliseconds. Long Currenttime=system.currenttimemillis (); SimpleDateFormat formatter = new SimpleDateFormat ("yyyy years mm DD Day hh mm min ss sec");  SimpleDateFormat formatter1=new SimpleDateFormat ("D-day of the Year in the year of the first W week January the first W week in the day K time Z time zone"); G-year marker//y//M/D Day//h in the morning or afternoon (1~12)//h in one day (0~23)//M min/s S/S//E Week//d in the first day of the year//F January the first few weeks/w mid-week//W January the first few weeks//a morning/afternoon marker//K when in the day (1~24)//k in the morning or afternoon (0~11)//Z Time zone date date=new date ( ); System.out.println (Formatter.format (date));    Calendar cal = Calendar.getinstance ();//Calendar provides a class method getinstance to obtain a generic object of this type. The getinstance method of the calendar returns a Calendar object that has been initialized by the current date and time: Date date1 = Cal.gettime ();       System.out.println (Formatter1.format (date1)); String osname = System.getproperty ("OS.Name ");       String user = System.getproperty ("User.Name");       SYSTEM.OUT.PRINTLN ("Current operating system is:" + osname);      System.out.println ("Current user is:" + user); }}

Results:

1440157503152233 Day 34th Monday Month 4th week in one day 11 o'clock GMT time zone The current operating system is: Windows NT (unknown) The current user is: Administrator

Java Date Class Summary

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.