about the use and differences of six time classes in Javajava.util.Datejava.sql.Date java.sql.Time java.sql.Timestamp Java.text.SimpleDateFormatJava.util.Calendar
Java.util.Date date format is: Month Day time minutes seconds
Java.sql.Date Date format: day of month
Java.sql.Time date format: hours and seconds
Java.sql.Timestamp Date format: Day of the month and seconds (nanosecond)
The dates taken from the database are generally used with the Gettimestamp () method, such as a field data type in Oracle date, and the Gettimestamp () method to obtain an accurate date.
Java.util.Calendar Class (Calendar Class) The Calendar class is an abstract base class used primarily for various calculations between dates to get a calendar instance: using the Calendar.getinstance () method or a constructor that calls its subclass GregorianCalendar.
Java.text.SimpleDateFormat: Five other types of time that can be formatted with the same style
----------------------------------------------------------------------------
Java.util.Date is the parent class of Java.sqldate,time,timestamp
1.java.util.date is used in cases other than SQL statements. 2.java.sql.date is used for SQL statements, new Java.sql.Date (New Java.util.Date (). GetTime (), which contains only dates and no time parts3. It has a gettime method to return the number of milliseconds---------------------------------------------------------------------------------------------4. Converting to each otherNew Java.sql.Date (New Java.util.Date (). GetTime ())New Java.util.Date (new Java.sql.Date (0). GetTime ())Use of 5.java.sql.timestamp6.java.sql.time 7.java.util.calendar8. All time dates can be SimpleDateFormat formatted format ()
The use and difference of six major time classes in Java