List of utility methods to do Timestamp Convert To
Date | convertDate(Timestamp time) convert Date return time == null ? null : new Date(time.getTime()); |
Timestamp | ConvertTimestamp(long sec) Convert Timestamp long unixSeconds = sec / 1000; Date date = new Date(unixSeconds * 1000L); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); sdf.setTimeZone(TimeZone.getTimeZone("GMT+8")); String dt = sdf.format(date); return Timestamp.valueOf(dt); |
Calendar | convertTimestamp(Timestamp timestamp) convert Timestamp if (timestamp == null) { return null; Calendar calendar = Calendar.getInstance(); calendar.setTime(timestamp); return calendar; |
Date | convertTimestampToDate(Timestamp timestamp) convert Timestamp To Date Date date = timestamp;
return date;
|
String | convertTimestampToDDMMMMYYYY(Timestamp dateTime) convert timestamp to format dd MMMM yyyy String s = ""; java.text.SimpleDateFormat ft = null; ft = new java.text.SimpleDateFormat("dd MMMM yyyy"); s = ft.format(dateTime); if (s.indexOf("Jan") > -1) { s = s.replace("January", "Januari"); } else if (s.indexOf("Feb") > -1) { s = s.replace("February", "Februari"); ... |
String | convertTimestampToString(Timestamp dateTime, String dateFormat) convert timestamp to format yyyyMMdd String s = ""; java.text.SimpleDateFormat ft = null; ft = new java.text.SimpleDateFormat(dateFormat); s = ft.format(dateTime); return s; |
String | convertTimestampToString(Timestamp str) convert Timestamp To String return convertTimestampToString(str, "yyyy-MM-dd HH:mm:ss"); |
String | convertTimestampToStringWithoutTime(final Timestamp ts) convert Timestamp To String Without Time final Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(ts.getTime()); return cal.get(Calendar.YEAR) + "-" + cal.get(Calendar.MONTH) + "-" + cal.get(Calendar.DAY_OF_MONTH); |
Date | convertToDate(Timestamp aTimeStamp) convert To Date Date res = null; if (aTimeStamp != null) { GregorianCalendar calendar = new GregorianCalendar(); calendar.setTime(new Date(aTimeStamp.getTime())); res = calendar.getTime(); return res; |
java.util.Date | convertToDate(Timestamp timestamp) convert To Date return new java.util.Date(timestamp.getTime()); |