Possible Duplicate:
How to calculate time difference in java?
I have two Strings "10:00:00" and "14:00:00". I have converted them to Date Format. Now i want two compare the both time.Can anyone suggest me what to do....
Possible Duplicate:
How to calculate time difference in java?
I have two Strings "10:00:00" and "14:00:00". I have converted them to Date Format. Now i want two compare the both time.Can anyone suggest me what to do....
Check Date#equals
, Date#after
, Date#before
I preferrably use Calendar
class for date related task.. It is quite to use them in some context..
You can find more helpful examples in this link
Before you do the comparison, as the timestamps are still in the String format, you need to convert them to java.util.Date and the simplest way is to assign an arbitrary date part to both time strings (e.g. concatenate both time strings to "1/1/1970 "), then convert them into Date using SimpleDateFormat, then get time in milliseconds and do the comparison.