List of utility methods to do Milliseconds
long | durationInMillis(long startNano) duration In Millis final long endNano = System.nanoTime(); return (endNano - startNano) / 1000000; |
String | elapsedMillis(long milliseconds) Returns a string representation of the specified elapsed time in the format "H hours M minutes S seconds". return elapsedNanos(1000000 * milliseconds);
|
long | elapsedMillis(long startTime) elapsed Millis return (long) elapsedTime(startTime, System.nanoTime(), 1e6); |
long | elapsedMillis(long t0nanos, long t1nanos) Get the elapsed milliseconds between two nano times return (t1nanos - t0nanos) / 1000000;
|
void | ensureSleepMillis(long millis) Ensures the current thread sleeps at least the given milliseconds before returning from this method. if (millis < 1) return; long now = System.currentTimeMillis(); final long targetTime = now + millis; do { Thread.sleep(millis); millis = targetTime - System.currentTimeMillis(); } while (millis > 0); ... |
String | expensiveMethodTakingMillis(final int millis) expensive Method Taking Millis try { Thread.sleep(millis); return "hi"; } catch (InterruptedException e) { throw new IllegalStateException(e); |
long | filetimeToMillis(long filetime) Converts a 64-bit NTFS time value (number of 100-nanosecond intervals since January 1, 1601 UTC) to a Java time value (number of milliseconds since January 1, 1970 UTC.) filetime -= 116444736000000000L; if (filetime < 0) { filetime = -1 - ((-filetime - 1) / 10000); } else { filetime = filetime / 10000; return filetime; |
String | formatDateMillis(long millis) format Date Millis String weekdays = "SunMonTueWedThuFriSat"; String months = "JanFebMarAprMayJunJulAugSepOctNovDec"; Calendar cal = Calendar.getInstance(); cal.setTime(new Date(millis)); return weekdays.substring((cal.get(Calendar.DAY_OF_WEEK) - 1) * 3).substring(0, 3) + " " + months.substring(cal.get(Calendar.MONTH) * 3).substring(0, 3) + " " + cal.get(Calendar.DATE) + " " + cal.get(Calendar.HOUR_OF_DAY) + ":" + (cal.get(Calendar.MINUTE) < 10 ? "0" : "") + cal.get(Calendar.MINUTE) + " " + cal.get(Calendar.YEAR); ... |
String | FormatDateTime(Calendar p_date, String p_seperator, boolean p_showMilliseconds) Format Date Time StringBuilder t_dateTime = new StringBuilder(); t_dateTime.append(FormatDate(p_date, p_seperator) + " "); t_dateTime.append(FormatTime(p_date.get(Calendar.HOUR_OF_DAY), p_date.get(Calendar.MINUTE), p_date.get(Calendar.SECOND), (p_showMilliseconds ? p_date.get(Calendar.MILLISECOND) : -1))); return t_dateTime.toString(); |
long | fractionOfDayToMilliseconds(float fFractionOfDay) Convert a duration that is based on fraction-of-a-day to milliseconds. float fDuration = (fFractionOfDay * 24 * 60 * 60 * 1000); return (long) fDuration; |