Java Utililty Methods Timestamp

List of utility methods to do Timestamp

Description

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

Method

CalendarsqlDateToCalendar(Timestamp date)
Converts the given SQL Date to a Calendar.
if (date == null) {
    return null;
} else {
    GregorianCalendar gc = new GregorianCalendar();
    gc.setTime(date);
    return gc;
DateSQLTimestampToDate(java.sql.Timestamp ts)
Convert a java.sql.timestamp into a java.util.date
Date date = new Date(ts.getTime());
return date;
java.util.DatesqlTimestampToDate(Timestamp t)
sql Timestamp To Date
return t != null ? new java.util.Date(Math.round(t.getTime() + t.getNanos() / 1000000D)) : null;
StringStrToDateTimeFormat(String timestampStr, String pattern)
Str To Date Time Format
String s = "";
try {
    s = String.valueOf(StrToTimestamp(timestampStr, pattern));
    s = s.substring(0, pattern.length());
} catch (Exception e) {
return s;
TimestampstrToTimestamp(String date)
str To Timestamp
Date day = strToDate(date);
return new Timestamp(day.getTime());
TimestampstrToTimestamp(String dateStr)
str To Timestamp
return Timestamp.valueOf(dateStr);
TimestampstrToTimestamp(String i_Today, String i_Hour, String i_Minute)
str To Timestamp
try {
    if (i_Today == null || i_Hour == null || i_Minute == null) {
        return null;
    java.util.Date d = strToDate(i_Today, i_Hour, i_Minute);
    return new java.sql.Timestamp(d.getTime());
} catch (Exception e) {
return null;
TimestampStrToTimestamp(String timestampStr, String pattern)
Str To Timestamp
java.util.Date date = null;
SimpleDateFormat format = new SimpleDateFormat(pattern);
try {
    date = format.parse(timestampStr);
} catch (ParseException ex) {
    throw ex;
return date == null ? null : new Timestamp(date.getTime());
...
Timestamptimestamp()
timestamp
return new Timestamp(DateTime.now().getMillis());
Timestamptimestamp(int year, int month, int day, int hour, int minute, int second, int nanosecond)
timestamp
Timestamp result = new Timestamp(millis(year, month, day, hour, minute, second));
result.setNanos(nanosecond);
return result;