Try {date.valueof (String Astring);} catch (exception ex) {system.err.println ("The Format of String is not correct");}
or
Public class forother {public static void main (String [] args) {SimpleDateFormat s = new SimpleDateFormat ("YYYY-MM-DD '' HH: mm: SS"); string = "2005-02-18 15:39: 15 "; string ppp =" 2005-02-01 15:25:15 "; try {date tt = s.Parse (OOO); Date Yy = S.PARSE (PPP); Long Aa; IF (tt.gettime )> yy.gettime ()) AA = tt.gettime () - yy.gettime (); else aa = yy.gettime () - tt.gettime (); long date = aa / 1000/60/60/24; System.out.println ("***"); system.out.println ("Hahahha"; System.out.Println ("*******");} catch (exception e) { }}}