List of utility methods to do Timestamp
Timestamp | trunc(Timestamp dayTime, String trunc) Get truncated day/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.set(Calendar.HOUR_OF_DAY, 0); ... |
Timestamp | truncateFractionalSeconds(Timestamp timestamp) truncate Fractional Seconds Timestamp truncatedTimestamp = new Timestamp(timestamp.getTime()); truncatedTimestamp.setNanos(0); return truncatedTimestamp; |
Timestamp | truncateTimestamp(Timestamp timestamp, String period) Truncate the specified field of a java.sql.Timestamp Timestamp ts = null; if (period != null) { Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(timestamp.getTime()); if (period.equalsIgnoreCase(HOURLY)) { cal.set(Calendar.MILLISECOND, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MINUTE, 0); ... |
Timestamp | truncNanos(Timestamp timestamp) trunc Nanos Timestamp ts = new Timestamp(timestamp.getTime()); ts.setNanos((ts.getNanos() / 1000000) * 1000000); return ts; |
String | unformattedFromTimestamp(java.sql.Timestamp t) Convert from a Timestamp to an unlocalized string with the format yyyymmddhhmmss. return unformattedFromTimestamp(t, true, false);
|
Timestamp | utcToTimestamp(String utcTimestamp) utc To Timestamp Timestamp timestamp; Date d = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").parse(utcTimestamp); timestamp = new Timestamp(d.getTime()); return timestamp; |
int | weekNumber(Timestamp stamp, TimeZone timeZone, Locale locale) week Number Calendar tempCal = toCalendar(stamp, timeZone, locale);
return tempCal.get(Calendar.WEEK_OF_YEAR);
|
void | writeTimestamp(ByteBuffer logBuf, Timestamp time) Write a timestamp into the log. writeLong(logBuf, time.getTime()); |
void | writeTimestamp(Timestamp stamp, ObjectOutput out, long nullFlag) write Timestamp if (stamp != null) { long value = stamp.getTime(); out.writeLong(value); } else { out.writeLong(nullFlag); |