Import java. Text .*;
Import java. util .*;
Public class test ...{
Public static void main (string [] ARGs) throws exception ...{
String str1 = new string ("1986-02-4 ");
String str2 = new string ("1986-2-8 ");
Java. Text. simpledateformat = new simpledateformat ("yyyy-mm-dd ");
Date d1 = simpledateformat. parse (str1 );
Date D2 = simpledateformat. parse (str2 );
Long DMM = d2.gettime ()-d1.gettime ();
Int d = (INT) DMM/1000/60/60/24;
System. Out. println (d );
String str3 = "20070101000000 ";
Simpledateformat F2 = new simpledateformat ("yyyymmddhhmmss ");
Date D3 = f2.parse (str3 );
System. Out. println (D3 );
}
}
The string type is changed to Java. SQL. Date.
If the character transfer meets the yyyy-mm-dd type
Java. SQL. Date time = java. SQL. Date. valueof ");
Pass the character to Java. SQL. date type. java. SQL. date is a subclass of Java. util. Date.