Java Utililty Methods Time Compare

List of utility methods to do Time Compare

Description

The list of methods to do Time Compare are organized into topic(s).

Method

longcompareStringTime(String t1, String t2, String parrten)
compare String Time
SimpleDateFormat formatter = new SimpleDateFormat(parrten);
ParsePosition pos = new ParsePosition(0);
ParsePosition pos1 = new ParsePosition(0);
java.util.Date dt1 = formatter.parse(t1, pos);
java.util.Date dt2 = formatter.parse(t2, pos1);
long l = dt1.getTime() - dt2.getTime();
return l;
intcompareTime(String time1, String time2)
compare Time
SimpleDateFormat sdf = new SimpleDateFormat(DEFAULT_DATE_PATTERN);
Date date1 = sdf.parse(time1);
Date date2 = sdf.parse(time2);
long result = date1.getTime() - date2.getTime();
if (result > 0) {
    return 1;
} else if (result == 0) {
    return 0;
...
booleancompareTime(String time1, String time2, String pattern)
compare Time
SimpleDateFormat format = new SimpleDateFormat(pattern);
Date d1 = null;
Date d2 = null;
d1 = format.parse(time1);
d2 = format.parse(time2);
return d1.before(d2);