Comparison between dates
Method 1:
String time1 = "08:08:08 ";
String time2 = "08:06:08 ";
Try {
SimpleDateFormat foramt = new SimpleDateFormat ("yyyy-MM-dd hh: MM: ss ");
Date mDate1 = foramt. parse (time1 );
Date mDate2 = foramt. parse (time2 );
Int result = mDate1.compareTo (mDate2 );
} Catch (ParseException e ){
E. printStackTrace ();
}
Method 2:
String time1 = "08:08:08 ";
String time2 = "08:06:08 ";
Try {
SimpleDateFormat foramt = new SimpleDateFormat ("yyyy-MM-dd hh: MM: ss ");
Date mDate1 = foramt. parse (time1 );
Date mDate2 = foramt. parse (time2 );
Long result = mDate1.getTime ()-mDate2.getTime ();
} Catch (ParseException e ){
E. printStackTrace ();
}
Method 3:
String time1 = "08:08:08 ";
String time2 = "08:06:08 ";
Try {
SimpleDateFormat foramt = new SimpleDateFormat ("yyyy-MM-dd hh: MM: ss ");
Date mDate1 = foramt. parse (time1 );
Date mDate2 = foramt. parse (time2 );
Boolean result = mDate1.after (mDate2 );
} Catch (ParseException e ){
E. printStackTrace ();
}