Summarize the conversion and comparison of date types
1.date-> String
SimpleDateFormat SDF = new SimpleDateFormat ("Yyyy-mm-dd");
String Date=sdf.format (new Date ());
2.string->date
SimpleDateFormat SDF = new SimpleDateFormat ("Yyyy-mm-dd");
Date date = Sdf.parse (datestring);
3.date->long
Java.util.Date dt = new Date ();
Long lSysTime1 = Dt.gettime ()/1000; Gets the number of seconds, the date type gettime () returns the number of milliseconds
4.long->date
SimpleDateFormat sdf= New SimpleDateFormat ("mm/dd/yyyy HH:mm:ss");
The previous lsystime is the number of seconds, first multiply by 1000 to get the number of milliseconds, then to java.util.Date type
Java.util.Date dt = new Date (LSYSTIME1 * 1000);
String sdatetime = sdf.format (DT); Get Accurate to SEC representation: 08/31/2006 21:08:00
5. Date type comparison
Date Date1=new date ();
Date Date2=new date ();
if (Date1.gettime () >date2.gettime ())
{
System.out.print ("Date1 greater than Date2");
}