Java Utililty Methods Milliseconds

List of utility methods to do Milliseconds

Description

The list of methods to do Milliseconds are organized into topic(s).

Method

longgetMillis(long timeInMinutes)
get Millis
return timeInMinutes * 60 * 1000;
longgetMillis(String _cal)
get Millis
int idx1 = _cal.indexOf("time");
int idx2 = _cal.indexOf(",");
return Long.parseLong(_cal.substring(idx1 + 5, idx2));
intgetMillis(String dateStr)
Returns the milli second part of the datetime.
int length = dateStr.length();
if (length == 19) {
    return 0;
} else if (length == 21) {
    return Integer.parseInt(dateStr.substring(20)) * 100;
} else if (length == 22) {
    return Integer.parseInt(dateStr.substring(20)) * 10;
} else if (length >= 23 && length <= 26) {
...
intgetMillis(String decimal)
Gets the number of millis represented by a String containing a decimal(8,3) type.
boolean isNegative;
if (decimal.length() > 0 && decimal.charAt(0) == '-') {
    isNegative = true;
    decimal = decimal.substring(1);
} else
    isNegative = false;
if (decimal.length() > 0 && decimal.charAt(0) == '.')
    decimal = '0' + decimal;
...
StringgetMillisDisplayable(long millis)
get Millis Displayable
String result = null;
final long second = 1000;
final long minute = 60 * second;
if (millis % minute == 0) {
    long minutes = millis / minute;
    if (minutes == 1) {
        result = minutes + " minute";
    } else {
...
longgetMilliSecond(Date d1, Date d2)
get Milli Second
long d1MS = d1.getTime();
long d2MS = d2.getTime();
return Math.abs(d1MS - d2MS);
intgetMillisecond(Date date)
get Millisecond
calendar.setTime(date);
return calendar.get(Calendar.MILLISECOND);
intgetMillisecond(String forDate)
get Millisecond
return Integer.parseInt(forDate.substring(20, 23));
longgetMilliSecondBetween(long start, long end)
get Milli Second Between
return (end - start) / (1000 * 1000);
LonggetMillisecondDay()
get Millisecond Day
return MILLISECOND_DAY;