List of utility methods to do Long Number to Timestamp
String | timestamp2DataTime(long timestamp) timestamp Data Time SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); return sdf.format(Long.valueOf(timestamp)); |
Date | timestamp2Date(long timestamp, String timezone) timestamp Date SimpleDateFormat dateFormatGmt = new SimpleDateFormat(DATE_FORMAT); dateFormatGmt.setTimeZone(TimeZone.getTimeZone(timezone)); SimpleDateFormat dateFormatLocal = new SimpleDateFormat(DATE_FORMAT); return dateFormatLocal.parse(dateFormatGmt.format(new Date(timestamp))); |
String | timestamp2DateTime(long t) convert a Unix timestamp to date time string String ret; SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); ret = sdf.format(t); return ret; |
String | timestampToHumanDateAndTime(long timestamp) Convert a timestamp to a humanly readable date and time. return m_dateAndTime.get().format(new Date(timestamp)); |
String | timestampToString(long micros) Transforms a timestamp into a string, whose formatting and timezone is consistent across Kudu. long tsMillis = micros / 1000L; long tsMicros = micros % 1000000L; String tsStr = DATE_FORMAT.get().format(new Date(tsMillis)); return String.format("%s.%06dZ", tsStr, tsMicros); |
String | timestampToString(long time) timestamp To String return time != -1 ? "until " + formatTimestamp(time) : "forever"; |
String | timestampToString(long timestamp) Convert a timestamp in a readable format for a human in the format : YYYY/mm/dd HH:mm:ss Calendar cal = GregorianCalendar.getInstance(); timestamp *= 1000; cal.setTimeInMillis(timestamp); SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss"); return cal.get(GregorianCalendar.YEAR) + "-" + (cal.get(GregorianCalendar.MONTH) + 1) + "-" + cal.get(GregorianCalendar.DAY_OF_MONTH) + " " + sdf.format(cal.getTime()); |
String | timeString(long timestamp) time String return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS", Locale.getDefault()).format(new Date(timestamp)); |
String | toDateTimeString(long timestamp) Converts a timestamp to string yyyy-mm-dd hh:mm:ss String DATE_FORMAT = "yyyy-MM-dd"; String TIME_FORMAT = "HH:mm:ss"; SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT); SimpleDateFormat stf = new SimpleDateFormat(TIME_FORMAT); return sdf.format(new Date(timestamp)) + "T" + stf.format(new Date(timestamp)); |
String | toSolrTimestamp(Long epoch) to Solr Timestamp SimpleDateFormat out = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); return out.format(epoch); |