Java Time Class Simple summary

Source: Internet
Author: User

                      Java Time Class (data Class)

1. Thedata class (without considering internationalization, many methods are obsolete in Java.util.Data package) the parent class (is the class is not the interface contains the direct subclass 3): Date format: Month day time seconds (not including the millisecond portion) Two ways to create: With the parameter constructor method (long parameter: data (long log)), without the parameters commonly used methods: after (), before (), CompareTo () and so on.

Direct subclass: Java.sql.Data (used to provide a representation of the database date) The date format is: month day (only date, no time) the class constructor must be a parameter (long millisecond level)

Direct subclass: Java.sql.Time (used to provide a representation of the database time) date format: cent seconds

Direct subclass: Java.sql.TimeStamp (used to provide a representation of the database time) date format: month day minute minute millisecond (1S=1000US)

2.Calender abstract class (used to replace Java.util.Data)

Parent class:Calender abstract class , which is a specific instant with a set such as (field): Year, MONTH, Day_of_month, HOUR

The conversion of calendar fields provides some methods. And for manipulating calendar fields, such as getting the date of the next week, provides a

Some methods. A millisecond value can be expressed instantaneously, which is the distance from the calendar element (00:00 Greenwich Mean Time 1997.1.1:

00.000, the Gregorian calendar) offset. As with other locale-sensitive classes, Calendar provides a static

Method:getinstance ()(because the Canlendar method is protected, the method can only be used to initially

To obtain a generic object of this type, which returns a Calendar object whose

Initialized by the current date and time . (Calendar.getinstance () indicates that the current time has been initialized).

Direct sub-class: GregorianCalendar

GregorianCalendar is a specific subclass of the Calendar that provides the most countries in the world with

Standard calendar System. is a hybrid calendar that supports both the Julian calendar and the Gregorian calendar with the support of a single discontinuity

System, by default, corresponds to the Gregorian calendar date. Can be called by Setgregorianchange ()

To change the starting Gregorian calendar date.

3.Format class (The time-date class is formatted as a parent class.) The formatted output of the date string class provides the format () method)

Time format: The formatclass and the Calendar class (both parallel)

Parent class: Java.text.Format

Subclass:Java.text.DateFormat abstract Class (the class is an abstract class of date, time formatting subclasses) It formats and parses dates or times in a language-independent manner

Descendants class: Java.text.SimpleDateFormat Date/Time formatting subclasses (SimpleDateFormat) allow formatting (that is, date-and text),

Analysis (text-to-date) and standardization. represents a date as a Date object, or is expressed as a time from GMT (Hotell gyllene Geten

Standard Time) 1970, January 1 00:00:00 The number of milliseconds to start this moment.

Example: SimpleDateFormat df = new SimpleDateFormat ("Yyyy-mm-dd,hh:mm:ss"); Df.format (New Date ()); The output time is:yyyy-mm-dd,hh:mm:ss

Java Time Class Simple 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.