Time in Java

Source: Internet
Author: User

1.System class Acquisition

  At the current time , the System class cannot be instantiated and needs to be called through its static method.

Use the System class Currenttimemillis () method to get the current system time. Returns the time in milliseconds, and the granularity of the value depends on the underlying operating system.

 Public Static long Currenttimemillis ()

Return value type: Long

long currenttime = system.currenttimemillis (); System.out.println (currenttime);

2.Date class

The class Date represents a specific instantaneous, accurate to milliseconds.

How to construct the Date class
Format Parameter list Description
Date () Null parameter Gets an object that represents the current system time
Date (long date)

An integer of type long, in milliseconds of absolute time

Null parameter gets the current time, specifying a long integer to get the time point corresponding to the integer

SYSTEM.OUT.PRINTLN (new//  Print current system time System.out.println (new//  Print absolute time 0 point in time information System.out.println (new//  Print absolute time the day before the point information

A

Time in Java

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.