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

StringgetDateString(java.sql.Timestamp ts)
get Date String
if (ts == null) {
    return "";
return Timestamp2DDMMYYYY(ts);
StringgetDateString(Timestamp time, String pattern)
get Date String
DateFormat dfmt = new SimpleDateFormat(pattern);
Date date = time;
return date != null ? dfmt.format(date) : "";
StringgetDateTime(Timestamp argRenDt)
This method converts timestamp to the specified datetime format
String strDate = null;
if (argRenDt != null) {
    SimpleDateFormat dtFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
    strDate = dtFormat.format(argRenDt);
return strDate;
DateTimegetDateTime(Timestamp timestamp)
get Date Time
return new DateTime(timestamp, GJChronology.getInstance(DateTimeZone.UTC));
StringgetDateTimeFromSqlTimestamp(Timestamp timestamp)
get Date Time From Sql Timestamp
if (timestamp != null) {
    return timestamp.toString().substring(0, 19);
return "";
DateTimegetDateTimeFromTimeStamp(Timestamp timestamp)
get Date Time From Time Stamp
return new DateTime(timestamp.getTime(), DateTimeZone.UTC);
DategetDateTimestamp(ResultSet rs, String columnLabel)
get Date Timestamp
Timestamp timestamp = rs.getTimestamp(columnLabel);
if (timestamp == null) {
    return null;
} else {
    return new Date(timestamp.getTime());
StringgetDateTimeStr(Timestamp timestamp)
get Date Time Str
if (timestamp == null) {
    return null;
Calendar cal = Calendar.getInstance();
cal.setTime(timestamp);
return cal.get(Calendar.DAY_OF_MONTH) + "/" + (cal.get(Calendar.MONTH) + 1) + "/" + cal.get(Calendar.YEAR)
        + " " + getFixedTwoStr(cal.get(Calendar.HOUR_OF_DAY)) + ":"
        + getFixedTwoStr(cal.get(Calendar.MINUTE));
...
StringgetDateTimeString(java.sql.Timestamp ts)
get Date Time String
if (ts == null) {
    return "";
return Timestamp2DDMMYYYY(ts) + " " + Timestamp2HHMMSS(ts, 1);
TimestampgetDayBorder(Timestamp dateTime, Timestamp timeSlot, boolean end)
Returns the day border by combining the date part from dateTime and time part form timeSlot.
GregorianCalendar gc = new GregorianCalendar();
gc.setTimeInMillis(dateTime.getTime());
dateTime.setNanos(0);
if (timeSlot != null) {
    timeSlot.setNanos(0);
    GregorianCalendar gcTS = new GregorianCalendar();
    gcTS.setTimeInMillis(timeSlot.getTime());
    gc.set(Calendar.HOUR_OF_DAY, gcTS.get(Calendar.HOUR_OF_DAY));
...