Java Utililty Methods Timestamp Compare

List of utility methods to do Timestamp Compare

Description

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

Method

intcompareTimestamp(final Timestamp d1, final Timestamp d2)
compare Timestamp
int res = compareDate(d1, d2);
if (res != 0) {
    return res;
return dCompare(d1.getHours(), d2.getHours(), d1.getMinutes(), d2.getMinutes(), d1.getSeconds(),
        d2.getSeconds());
booleancompareTimestamps(Timestamp minTimestamp, Timestamp maxTimestamp)
compare Timestamps
return maxTimestamp.after(minTimestamp);
intcompareTimestamps(Timestamp timestamp1, Timestamp timestamp2)
Utility method to compare timestamps that avoid NPEs when one of the timestamps is null
if (timestamp1 != null) {
    if (timestamp2 != null) {
        return timestamp1.compareTo(timestamp2);
    } else {
        return 1;
} else {
    if (timestamp2 != null) {
...
floatdateDiff(Timestamp t1, Timestamp t2, int type)
date Diff
float i = t1.getTime() - t2.getTime();
float f = 0.0f;
switch (type) {
case 1:
    f = i / (1000 * 60 * 60);
    break;
case 2:
    f = i / (1000 * 60);
...
IntegerdateDifference(Timestamp one, Timestamp two)
Returns the number of days between the beginning of two days.
Calendar first = Calendar.getInstance();
Calendar second = Calendar.getInstance();
first.setTime(one);
second.setTime(two);
first.set(Calendar.HOUR_OF_DAY, 0);
first.set(Calendar.MINUTE, 0);
first.set(Calendar.SECOND, 0);
second.set(Calendar.HOUR_OF_DAY, 0);
...