Here you can find the source of millisecondsTo(long milliseconds, final TimeUnit timeUnit)
public static long millisecondsTo(long milliseconds, final TimeUnit timeUnit)
//package com.java2s; //License from project: Apache License import java.util.concurrent.TimeUnit; public class Main { public static long millisecondsTo(long milliseconds, final TimeUnit timeUnit) { switch (timeUnit) { case MILLISECONDS: return TimeUnit.MILLISECONDS.toMillis(milliseconds); case NANOSECONDS: return TimeUnit.MILLISECONDS.toNanos(milliseconds); case MICROSECONDS: return TimeUnit.MILLISECONDS.toMicros(milliseconds); case SECONDS: return TimeUnit.MILLISECONDS.toSeconds(milliseconds); case MINUTES: return TimeUnit.MILLISECONDS.toMinutes(milliseconds); case HOURS: return TimeUnit.MILLISECONDS.toHours(milliseconds); case DAYS: return TimeUnit.MILLISECONDS.toDays(milliseconds); default:/*from ww w .ja v a2s. co m*/ throw new IllegalArgumentException(); } } }