List of utility methods to do Millisecond Convert
String | getDuration(final long millis) get Duration DecimalFormat df20 = new DecimalFormat("00"); DecimalFormat df30 = new DecimalFormat("000"); Calendar c = Calendar.getInstance(TimeZone.getTimeZone("UTC")); c.setTimeInMillis(millis); return new StringBuffer(12).append(df20.format(c.get(Calendar.HOUR_OF_DAY))).append(":") .append(df20.format(c.get(Calendar.MINUTE))).append(":").append(df20.format(c.get(Calendar.SECOND))) .append(".").append(df30.format(c.get(Calendar.MILLISECOND))).toString(); |
String | getDurationBreakdown(long durationInMillis) Convert a millisecond duration to a string format if (durationInMillis < 0) { throw new IllegalArgumentException("Duration must be greater than zero!"); return (new SimpleDateFormat("mm:ss:SSS")).format(new Date(durationInMillis)); |
long | getDurationMillisecond(Date date1, Date date2) get Duration Millisecond return date2.getTime() - date1.getTime();
|
String | getHumanDisplayForTimediff(Long diffMillis) get Human Display For Timediff if (diffMillis == null) { return ""; long day = diffMillis / (24 * 60 * 60 * 1000); long hour = (diffMillis / (60 * 60 * 1000) - day * 24); long min = ((diffMillis / (60 * 1000)) - day * 24 * 60 - hour * 60); long se = (diffMillis / 1000 - day * 24 * 60 * 60 - hour * 60 * 60 - min * 60); StringBuilder sb = new StringBuilder(); ... |
String | getNice(long timeMillisecGMT) Return nice given MMILIS since EPOCH SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); format.setTimeZone(TimeZone.getTimeZone("GMT")); return format.format(new Date(timeMillisecGMT)); |
String | getStringFromMillis(long timestamp) get String From Millis DateFormat df = DateFormat.getDateTimeInstance(); return df.format(new Date(timestamp)); |
String | getTime(long millis) get Time return formattor.format(new Date(millis)); |
String | getTime(long time, boolean withMilliseconds) get Time SimpleDateFormat dateFormat = getDateFormat(withMilliseconds); return dateFormat.format(new Date(time)); |
String | getTimeByMillis(long now) get Time By Millis DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(now); return formatter.format(calendar.getTimeInMillis()); |
String | getTimeFromMillisAsNICSDate(long timeInMillis) get Time From Millis As NICS Date SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); fmt.setTimeZone(TimeZone.getTimeZone("UTC")); return fmt.format(getDateFromMillis(timeInMillis)); |