List of utility methods to do Millisecond Convert
String | convertMillisToHumanReadableForm(long milliseconds) convert Millis To Human Readable Form if (milliseconds < 0) { return "CANNOT_CONVERT"; if (milliseconds > 86400000) { return getNumberOfDays(milliseconds); } else { return getNumberOfHours(milliseconds); |
String | convertMillisToString(long diff) convert Millis To String if (diff == 0) return ""; try { long number = 0; String unit = ""; if (diff / MILLIS_PER_YEAR > 0) { number = diff / MILLIS_PER_YEAR; unit = "year"; ... |
long | convertMillisToTicks(long milliseconds) Convert milliseconds to minecraft ticks (20th of a second). double nearestTickTime = round(milliseconds, 50); return (long) ((nearestTickTime / 1000) * 20); |
String | convertMillisToTime(String val) Convert millis to time. long milliseconds = Long.parseLong(val); long seconds, minutes, hours; seconds = milliseconds / 1000; minutes = seconds / 60; seconds = seconds % 60; hours = minutes / 60; minutes = minutes % 60; if (hours > 0) { ... |
String | convertNanosecondToMillisecondString(final long nanos) This method creates a microsecond string or, if zero microseconds, a two digit decimal representation. final String longString = Long.toString(nanos); final long ms = nanos / 1000000; if (0 == ms) { if (longString.length() == 6) { return "." + longString.substring(0, 3); } else if (longString.length() == 5) { return ".0" + longString.substring(0, 2); } else if (longString.length() == 4) { ... |
String | convertTimeMillisToHexString(long currentDate) convert Time Millis To Hex String return String.format("%012x", currentDate); |
long | convertTimeToDurationMilliseconds(String time) Convert a time string in format HH:MM:SS in a milliseconds duration. long retObj = 0; if (time != null) { try { Integer hours = Integer.valueOf(time.substring(0, 2)); Integer minutes = Integer.valueOf(time.substring(3, 5)); Integer seconds = Integer.valueOf(time.substring(6, 8)); retObj += hours * 60 * 60 * 1000; retObj += minutes * 60 * 1000; ... |
int | convertToMillis(float timeInSeconds) convert To Millis return (int) (timeInSeconds * 1000f); |
int | convertToMillis(String time) convert To Millis int millis = 100; try { millis = Integer.parseInt(time); } catch (NumberFormatException nfe) { System.out.println("" + nfe.getMessage()); nfe.printStackTrace(); return millis; ... |
long | convertToMilliseconds(String value) convert To Milliseconds long multiplier = 1; if (value.endsWith("ms")) { value = value.substring(0, value.length() - 2).trim(); } else if (value.endsWith("min")) { value = value.substring(0, value.length() - 3).trim(); multiplier = 60 * 1000; } else if (value.endsWith("mins")) { value = value.substring(0, value.length() - 4).trim(); ... |