Java TimeUnit Calculate getMilliseconds(int interval, TimeUnit unit)

Here you can find the source of getMilliseconds(int interval, TimeUnit unit)

Description

get Milliseconds

License

Open Source License

Declaration

public static long getMilliseconds(int interval, TimeUnit unit) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.concurrent.TimeUnit;

import org.joda.time.DateTimeConstants;

public class Main {
    public static long getMilliseconds(int interval, TimeUnit unit) {

        long millisPerUnit = 1;

        switch (unit) {
        case DAYS:
            millisPerUnit = DateTimeConstants.MILLIS_PER_DAY;
            break;
        case HOURS:
            millisPerUnit = DateTimeConstants.MILLIS_PER_HOUR;
            break;
        case MINUTES:
            millisPerUnit = DateTimeConstants.MILLIS_PER_MINUTE;
            break;
        case SECONDS:
            millisPerUnit = DateTimeConstants.MILLIS_PER_SECOND;
            break;
        default:/*from  w w  w .  java  2 s .c om*/
            break;
        }

        return interval * millisPerUnit;
    }
}

Related

  1. getExpiringMap(long time, TimeUnit unit)
  2. getFragment(final Calendar calendar, final int fragment, final TimeUnit unit)
  3. getFutureDate(long delay, TimeUnit timeUnit)
  4. getInterval(final Date startDate, final Date endDate, final TimeUnit timeUnit)
  5. getIntervalInfo(long intervalDuration, TimeUnit unit)
  6. getNowTimeUnit(TimeUnit timeUnit)
  7. getParentUnit(TimeUnit unit)
  8. getProperUnitName(TimeUnit unit, long amount)
  9. getRandomTimeRound(int _duration, TimeUnit _unit)