Java Get system time

Source: Internet
Author: User

Java can format the date by using the SimpleDateFormat format class to get the time.

1 ImportJava.util.*;2 Importjava.text.*;3  Public classTestDate {4    Public Static voidMain (String args[]) {5Date today=NewDate ();6SimpleDateFormat f=NewSimpleDateFormat ("yyyy mm month DD Day HH:MM:SS");7String time=F.format (today);8 System.out.println (time);9   }Ten}

The format is as follows:

YYYY represents the year, such as 2016;

MM represents the month, such as 12;

DD denotes days, such as 31;

HH indicates a 12-hour system, such as 7;

HH indicates a 24-hour system, such as 18;

MM for points, such as 59;

The SS represents seconds, such as 59;

SSS represents millimeters, such as 333.

Java Get system time

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.