Use of the Java time class

Source: Internet
Author: User
Tags cst time time zones

Use of Date:

1. Date of Creation

2. Date format display

3. Conversion of dates

4, two date size comparison, date of the addition and subtraction

Some knowledge:

Carve-out of 24 time zones worldwide

Greenwich Mean Time GMT


World Coordination Time (world standard Time) UTC

Summer Time saving DST

CST Time

CST can also represent the following 4 different time zones:

Central Standard Time (USA) ut-6:00

Central Standard Time (Australia) ut+9:30

China Standard Time ut+8:00

Cuba Standard Time ut-4:00

CST can also represent the standard time in four countries of the United States, Australia, China, and Cuba.

Date class

The date class can get the current time, a comparison of two date types, a date type of milliseconds, but many methods and obsolete. If you get a specific date, time, and seconds.

New Date ();         New Date ();        Date.after (datetwo);        Date.compareto (datetwo);

Calendar class

The Calendar class is an abstract class that provides a class method getinstance. From the calendar instance, you can get information about the time zone for the month and day.

The calendar week is starting from Sunday, with a constant value of 0.

The month of the calendar is starting in January with a constant value of 0.

The first day of the month of the calendar has a value of 1.

Calendar instance = calendar.getinstance ();         int i = instance.get (calendar.date);         int i1 = instance.get (calendar.hour);         int i2 = instance.get (calendar.month);        System.out.println ("i2 =" + I2 + ", I1 =" + I1 + ", i=" + i);

SimpleDateFormat class

DateTime 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.