Common date methods
Return type |
Method Name |
Remarks |
Date |
New Date () |
Create current date object |
Date |
New Date (long DT) |
Use the specified number of milliseconds since January 1, to create a date |
Boolean |
Before (date D) |
Returns true if it is before the specified date. |
Boolean |
After (date D) |
After |
Long |
Gettime () |
Returns the number of milliseconds from 1970.1.1. |
Void |
Settime (long time) |
Set date |
Boolean |
Equals (Object OBJ) |
Judge whether the date is equal |
String |
Tostring () |
Format date |
Common Methods of simpledateformat class
Return type |
Method Name |
Remarks |
|
New simpledateformat () |
Create object |
|
New simpledateformat (string pattern) |
Specify format to create an object |
String |
Format (Object OBJ) |
Format the generated string of an object. |
Date |
Parse (string text) |
Generate a date |
Calendar |
Getcalendar () |
Get the calendar associated with this date/time formatter |
Dateformat |
Getinstance () |
Get the short-style default date/time Formatter for date and time |
/************* Date and simpledateformat *****************/
// Public static void main (string [] ARGs ){
// Date = new date ();
// System. Out. println (date); // output the current date
// System. Out. println (date. gettime (); // returns the number of milliseconds since January 1 ,.
//
// Simpledateformat SDF = new simpledateformat ("yyyy-mm-dd hh: mm: SS ");
// System. Out. println (SDF. Format (date); // format the date
//}