Java Milli Second to Minute daysHoursMinutesToMillis(String expression)

Here you can find the source of daysHoursMinutesToMillis(String expression)

Description

Computes milliseconds from an expression [dd:][HH:]mm.

License

Open Source License

Parameter

Parameter Description
expression string representing time in [days:][hours:]minutes.

Return

corresponding time in milliseconds.

Declaration

public static long daysHoursMinutesToMillis(String expression) 

Method Source Code

//package com.java2s;

public class Main {
    private static final long[] MILLIS_EQUIV = { 24 * 60 * 60 * 1000, 60 * 60 * 1000, 60 * 1000 };

    /**// w w  w  .  j a  va 2  s  .c o m
     * Computes milliseconds from an expression [dd:][HH:]mm.
     * 
     * @param expression
     *            string representing time in [days:][hours:]minutes.
     * @return corresponding time in milliseconds.
     */
    public static long daysHoursMinutesToMillis(String expression) {
        String[] ddHHmm = expression.split(":");
        long total = 0;
        int j = 2;
        for (int i = ddHHmm.length - 1; i >= 0; i--)
            total += (Integer.parseInt(ddHHmm[i]) * MILLIS_EQUIV[j--]);
        return total;
    }
}

Related

  1. _toBeginOfMinute(long millis)
  2. asHoursMinutesSeconds(long milliseconds)
  3. daysHoursMinutes(long p_milliseconds)
  4. hoursMinutes(long p_milliseconds)
  5. isLessThanMinute(final long timeInMillis)
  6. isSameMinuteOfMillis(final long ms1, final long ms2)
  7. millis2minutes(long millis)