Java Utililty Methods Timestamp Field

List of utility methods to do Timestamp Field

Description

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

Method

LocalTimegetLocalTime(final Timestamp timestamp)
get Local Time
return timestamp != null ? timestamp.toLocalDateTime().toLocalTime() : null;
TimestampgetMessageTimestamp(int id)
get Message Timestamp
Timestamp t = null;
return t;
TimestampgetMillTimestamp()
get Mill Timestamp
return new Timestamp(System.currentTimeMillis());
TimestampgetMonthEnd(Timestamp stamp, TimeZone timeZone, Locale locale)
get Month End
Calendar tempCal = toCalendar(stamp, timeZone, locale);
tempCal.set(tempCal.get(Calendar.YEAR), tempCal.get(Calendar.MONTH),
        tempCal.getActualMaximum(Calendar.DAY_OF_MONTH), 0, 0, 0);
return getDayEnd(new Timestamp(tempCal.getTimeInMillis()), timeZone, locale);
TimestampgetMonthLastDay(Timestamp day)
Get last date in month
if (day == null)
    day = new Timestamp(System.currentTimeMillis());
GregorianCalendar cal = new GregorianCalendar();
cal.setTimeInMillis(day.getTime());
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
...
java.sql.TimestampgetMonthStart(java.sql.Timestamp stamp)
Return the date for the first day of the month
return getMonthStart(stamp, 0, 0);
TimestampgetMonthStartTimestamp(Date date)
get Month Start Timestamp
Date start = getMonthStartDate(date);
return new Timestamp(start.getTime());
intgetNanos(Timestamp timestamp)
get Nanos
return timestamp.getNanos();
StringgetNanoString(Timestamp timestamp, boolean full, char nanoSep)
Gets nano string suffix of a timestamp.
String zeros = "000000000";
int nanos = timestamp.getNanos();
String nanosString = Integer.toString(nanos);
nanosString = zeros.substring(0, (9 - nanosString.length())) + nanosString;
char[] nanosChar = new char[nanosString.length()];
nanosString.getChars(0, nanosString.length(), nanosChar, 0);
int truncIndex = 8;
while (truncIndex > 0 && nanosChar[truncIndex] == '0') {
...
intgetNbHours(Timestamp dateA, Timestamp dateB)
get Nb Hours
return (int) ((dateB.getTime() - dateA.getTime()) / 3600000);