Java Utililty Methods Timestamp Convert To

List of utility methods to do Timestamp Convert To

Description

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

Method

CalendartoCalendar(final Timestamp ts)
Converts a SQL timestamp into a Calendar .
final Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(ts.getTime());
return cal;
java.util.CalendartoCalendar(java.sql.Timestamp stamp)
to Calendar
Calendar cal = Calendar.getInstance();
if (stamp != null) {
    cal.setTimeInMillis(stamp.getTime());
return cal;
CalendartoCalendar(Timestamp stamp)
to Calendar
Calendar cal = Calendar.getInstance();
if (stamp != null) {
    cal.setTimeInMillis(stamp.getTime());
return cal;
CalendartoCalendar(Timestamp timestamp)
to Calendar
Calendar cal = Calendar.getInstance();
cal.setTime(timestamp);
return cal;
java.util.DatetoDate(java.sql.Timestamp timestamp)
Convert java.sql.Timestamp to java.util.Date
if (timestamp != null) {
    long milliseconds = timestamp.getTime();
    return new java.util.Date(milliseconds);
return null;
DatetoDate(Timestamp timestamp)
to Date
return new Date(timestamp.getTime());
DateTimetoDateTime(Timestamp value)
Null-safe method of converting a SQL Timestamp into a DateTime that it set specifically to be in UTC.
if (value == null) {
    return null;
} else {
    return new DateTime(value.getTime(), DateTimeZone.UTC);
BigDecimaltoDecimal(Timestamp instant)
to Decimal
long millis = instant.getTime();
long secs = millis / 1000;
return new BigDecimal(toDecimal(secs, instant.getNanos()));
StringtoEnglishDateTime(java.sql.Timestamp ts)
given timestamp object and return string format of yyyy-mm-dd

String oracleDate = "";
if (ts != null) {
    oracleDate = ts.toString().substring(0, 16);
    oracleDate = toEnglishDateTime(oracleDate);
return oracleDate;
StringtoEnglishHours(java.sql.Timestamp ts)
given timestamp object and return string format of hh

String hours = "";
if (ts != null) {
    hours = ts.toString();
    int index = hours.indexOf(":");
    hours = hours.substring(index - 2, index);
return hours;