Java-date class

Source: Internet
Author: User

Package Com.day10.Date class;

Import Java.util.Date;

public class Demodate {

/**
* Common Objects (Overview of the date class and methods used) (master)
* Overview of the A:date class
* Class Date represents a specific moment, accurate to milliseconds.
* B: Construction method
* Public Date ()
* Public date (long date)
* C: Member method
* Public long GetTime ()
* public void SetTime (long time)
*/
public static void Main (string[] args) {
Date D1=new date ();//null parameter constructor
System.out.println (d1);//sat Dec 21:09:40 CST 2017, representing the current time

Date D2=new date (0);
System.out.println (D2);//thu Jan 08:00:00 CST 1970, why print out is 8 points instead of 0 points, because Beijing in the East eight district

System.out.println (D1.gettime ());//Gets the millisecond value of the current time
System.out.println (System.currenttimemillis ());//Gets the millisecond value of the current time

Date D3=new date ();
D3.settime (1000);//Set the millisecond value, change the time object, past 1000 milliseconds
SYSTEM.OUT.PRINTLN (D3);//thu Jan 08:00:01 CST 1970

}

}

Java-date class

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.