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

longconvertToEpochMillis(java.sql.Timestamp ts)
convert To Epoch Millis
return ts.getTime();
StringconvertToISO8601String(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;
StringconvertToString(Timestamp dateData, String pattern, Locale locale)
convert To String
if (dateData == null) {
    return null;
SimpleDateFormat formatter = new SimpleDateFormat(pattern, locale);
return formatter.format(dateData);
longtimestamp(Timestamp timestamp)
timestamp
if (timestamp == null)
    return 0;
return timestamp.getTime();
StringTimestamp2Arch(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;
Calendartimestamp2Calendar(Timestamp ts)
timestamp Calendar
Calendar c = Calendar.getInstance();
c.setTime(ts);
return c;
java.util.Datetimestamp2Date(java.sql.Timestamp t)
timestamp Date
return new java.util.Date(t.getTime());
Stringtimestamp2Internal(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.Timestamptimestamp2ToTimestamp(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;
DatetimestampSqlToDate(Timestamp timestamp)
Creates new instance of java.util.Date based on timestamp.
if (timestamp == null) {
    return null;
return new Date(timestamp.getTime());