List of utility methods to do Timestamp
boolean | isValid(Timestamp validFrom, Timestamp validTo, Timestamp testDate) Is it valid on test date if (testDate == null) return true; if (validFrom == null && validTo == null) return true; if (validFrom != null && validFrom.after(testDate)) return false; if (validTo != null && validTo.before(testDate)) return false; ... |
Timestamp | long2Timestamp(Long longValue) long Timestamp return new Timestamp(longValue); |
long | longFromTimestamp(Timestamp ts) Returns the number of milliseconds since the epoch represented by the time stamp ts , or #NULL_TIME if ts is null .
if (ts == null) { return NULL_TIME; return ts.getTime(); |
Timestamp | max(Timestamp ts1, Timestamp ts2) Max date if (ts1 == null) return ts2; if (ts2 == null) return ts1; if (ts2.after(ts1)) return ts2; return ts1; |
Timestamp | maxTime(Timestamp dayTime) max Time if (dayTime == null) dayTime = new Timestamp(System.currentTimeMillis()); GregorianCalendar cal = new GregorianCalendar(); cal.setTimeInMillis(dayTime.getTime()); cal.set(Calendar.MILLISECOND, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MINUTE, 0); cal.add(GregorianCalendar.DAY_OF_YEAR, 1); ... |
Timestamp | minusHours(Timestamp ts, int hours) minus Hours DateTime dateTime = new DateTime(ts.getTime(), DateTimeZone.UTC); DateTime retval = dateTime.minusHours(hours); Timestamp retts = new Timestamp(retval.getMillis()); retts.setNanos(ts.getNanos()); return retts; |
Timestamp | minusOneSecond(Timestamp now) minus One Second return new Timestamp(now.getTime() - 1000); |
Date | newDate(Timestamp time) new Date return new Date(time.getTime()); |
java.sql.Timestamp | newTimestamp() Create a new Timestamp. return new java.sql.Timestamp(System.currentTimeMillis()); |
Timestamp | newTimestamp(Date date) new Timestamp return newTimestamp(date.getTime());
|