List of utility methods to do Timestamp Convert To
long | convertToEpochMillis(java.sql.Timestamp ts) convert To Epoch Millis return ts.getTime();
|
String | convertToISO8601String(java.sql.Timestamp ts) convert To ISO String DateTimeFormatter fmt = ISODateTimeFormat.dateTime(); DateTime dateTime = new DateTime(ts.getTime(), DateTimeZone.UTC); String retval = fmt.print(dateTime); return retval; |
String | convertToString(Timestamp dateData, String pattern, Locale locale) convert To String if (dateData == null) { return null; SimpleDateFormat formatter = new SimpleDateFormat(pattern, locale); return formatter.format(dateData); |
long | timestamp(Timestamp timestamp) timestamp if (timestamp == null) return 0; return timestamp.getTime(); |
String | Timestamp2Arch(Timestamp ts) convert a SQL Timestamp object to Archive format (YYYY-MM-DD HH:MM:SS) String tsString = ts.toString(); int ind = tsString.lastIndexOf("."); if (ind > 0) tsString = tsString.substring(0, ind); return tsString; |
Calendar | timestamp2Calendar(Timestamp ts) timestamp Calendar Calendar c = Calendar.getInstance();
c.setTime(ts);
return c;
|
java.util.Date | timestamp2Date(java.sql.Timestamp t) timestamp Date return new java.util.Date(t.getTime()); |
String | timestamp2Internal(java.sql.Timestamp t) Converts a Timestamp into the internal encoding as defined above. if (t == null) return ""; long seconds = t.getTime() / 1000; int nanos = t.getNanos(); return String.valueOf(seconds) + " " + String.valueOf(nanos); |
java.sql.Timestamp | timestamp2ToTimestamp(long seconds, int fraction, int width) timestamp To Timestamp final java.sql.Timestamp r = new java.sql.Timestamp(seconds * 1000L); r.setNanos(nanosForFractionalValue(fraction, width)); return r; |
Date | timestampSqlToDate(Timestamp timestamp) Creates new instance of java.util.Date based on timestamp. if (timestamp == null) { return null; return new Date(timestamp.getTime()); |