List of utility methods to do Timestamp Convert To
Calendar | toCalendar(final Timestamp ts) Converts a SQL timestamp into a Calendar . final Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(ts.getTime()); return cal; |
java.util.Calendar | toCalendar(java.sql.Timestamp stamp) to Calendar Calendar cal = Calendar.getInstance(); if (stamp != null) { cal.setTimeInMillis(stamp.getTime()); return cal; |
Calendar | toCalendar(Timestamp stamp) to Calendar Calendar cal = Calendar.getInstance(); if (stamp != null) { cal.setTimeInMillis(stamp.getTime()); return cal; |
Calendar | toCalendar(Timestamp timestamp) to Calendar Calendar cal = Calendar.getInstance();
cal.setTime(timestamp);
return cal;
|
java.util.Date | toDate(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; |
Date | toDate(Timestamp timestamp) to Date return new Date(timestamp.getTime()); |
DateTime | toDateTime(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); |
BigDecimal | toDecimal(Timestamp instant) to Decimal long millis = instant.getTime(); long secs = millis / 1000; return new BigDecimal(toDecimal(secs, instant.getNanos())); |
String | toEnglishDateTime(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; |
String | toEnglishHours(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; |