List of utility methods to do Timestamp Field
int | getDiffSecond(long orgTimestamp, long desTimestamp) get Diff Second return (int) ((orgTimestamp - desTimestamp) / 1000); |
long | getDiffTime(Timestamp last) get Diff Time Date date = new Date(); Timestamp now = new Timestamp(date.getTime()); long nowSec = now.getTime() / 1000; long lastSec = last.getTime() / 1000; if (nowSec > lastSec) { return nowSec - lastSec; } else { return lastSec - nowSec; ... |
int | getDiffYear(java.sql.Timestamp start, java.sql.Timestamp end) Gets the diff year. return end.getYear() - start.getYear();
|
int | getDiscrepancyNum(Timestamp time1, Timestamp time2) get Discrepancy Num int result = 0; if (time1 != null && time2 != null) { long temp = time1.getTime() - time2.getTime(); if (temp > 0) { result = (int) ((temp / (24 * 60 * 60 * 1000))); } else { result = -(int) (((temp / (24 * 60 * 60 * 1000)))); return result; |
double | getDouble(Timestamp ts) Convert the timestamp to a double measured in seconds. long seconds = millisToSeconds(ts.getTime()); return seconds + ((double) ts.getNanos()) / 1000000000; |
Long | getDuration(final Timestamp start, final Date end) Return the duration of a time interval (end-start) in milliseconds. return ((start == null) || (end == null)) ? null : new Long(start.getTime() - end.getTime()); |
String | getDurationHour(Timestamp time1, Timestamp time2, String direction) get Duration Hour String f = direction; if (f == null) { f = "+"; long ctime1 = System.currentTimeMillis(); long ctime2 = System.currentTimeMillis(); if (time1 != null) { ctime1 = time1.getTime(); ... |
String | getDurationMinute(Timestamp createTime, Timestamp finishTime) get Duration Minute String rtn = "0min"; if (createTime == null) { return rtn; long ctime = createTime.getTime(); BigDecimal ct = new BigDecimal(Long.toString(ctime)); long ftime = System.currentTimeMillis(); if (finishTime != null) { ... |
Timestamp | getEndTimeOfMonth(Timestamp timestamp) get End Time Of Month Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(timestamp.getTime()); calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH)); calendar.set(Calendar.HOUR_OF_DAY, calendar.getActualMaximum(Calendar.HOUR_OF_DAY)); calendar.set(Calendar.MINUTE, calendar.getActualMaximum(Calendar.MINUTE)); calendar.set(Calendar.SECOND, calendar.getActualMaximum(Calendar.SECOND)); calendar.set(Calendar.MILLISECOND, calendar.getActualMaximum(Calendar.MILLISECOND)); return new Timestamp(calendar.getTimeInMillis()); ... |
Date | getEndTimeStampOfDate(Date date) get End Time Stamp Of Date if (date == null) return null; String yyyymmdd = makeYYYYMMDD(date); StringTokenizer tokenizer = new StringTokenizer(yyyymmdd, "/"); int year = Integer.parseInt(tokenizer.nextToken()); int month = Integer.parseInt(tokenizer.nextToken()); int day = Integer.parseInt(tokenizer.nextToken()); return new Timestamp(makeDateTime(year, month, day, 23, 59, 59).getTime()); ... |