List of utility methods to do Timestamp
Timestamp | getCurTimestamp() get Cur Timestamp return Timestamp.valueOf(formatTimestamp.format(new Date())); |
java.sql.Timestamp | getCurTimestamp() get Cur Timestamp java.util.Date today = new java.util.Date(); java.sql.Timestamp ts = new java.sql.Timestamp(today.getTime()); return ts; |
String | getTimeDifference(Timestamp startTime, Timestamp endTime) Gets the time difference. long timeInMilliseconds = endTime.getTime() - startTime.getTime(); int seconds = (int) (timeInMilliseconds / 1000); int minutes = seconds / 60; int milliseconds = (int) (timeInMilliseconds % 1000); return minutes + " minute(s) " + seconds + " second(s) " + milliseconds + " millisecond(s)"; |
java.sql.Time | getTimeFromTimestamp(java.sql.Timestamp tsZeitpunkt) get Time From Timestamp if (tsZeitpunkt == null) { return null; Calendar c = Calendar.getInstance(); c.setTimeInMillis(tsZeitpunkt.getTime()); long l = -MILLISEKUNDEN_EINER_STUNDE; l += c.get(Calendar.HOUR_OF_DAY) * MILLISEKUNDEN_EINER_STUNDE; l += c.get(Calendar.MINUTE) * MILLISEKUNDEN_EINER_MINUTE; ... |
long | getTimeNanoSec(Timestamp t) get Time Nano Sec long time = t.getTime(); int nanos = t.getNanos(); return (time * 1000000) + (nanos % 1000000); |
Timestamp | getTimeNextDay(Timestamp date) get Time Next Day long time = date.getTime(); time = time + 24 * 60 * 60 * 1000; return new Timestamp(time); |
Timestamp | getTimeNextMonthFirstSec(Timestamp sysDate) get Time Next Month First Sec Calendar calendar = Calendar.getInstance(); calendar.setTime(sysDate); calendar.add(Calendar.MONTH, 1); calendar.set(Calendar.DAY_OF_MONTH, 1); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); ... |
String | getTimePassedSince(Timestamp timestamp) get Time Passed Since String result = null; Timestamp currentTime = getCurrentTimestamp(); long diff = currentTime.getTime() - timestamp.getTime(); boolean flag = false; if (diff >= 0) { if (diff >= YEAR && !flag) { long d = diff / YEAR; flag = true; ... |
String | getTimeStr(Timestamp tsp) get Time Str if (tsp == null) { return ""; return dateToStr(new Date(tsp.getTime())); |
String | getTimeString(java.sql.Timestamp ts) get Time String java.util.Calendar calendar = java.util.Calendar.getInstance(); calendar.setTime(new java.util.Date(ts.getTime())); return calendar.get(calendar.HOUR_OF_DAY) + ":" + calendar.get(calendar.MINUTE) + ":" + calendar.get(calendar.SECOND); |