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