Here you can find the source of convertTo(long a, TimeUnit from, TimeUnit to)
public static long convertTo(long a, TimeUnit from, TimeUnit to)
//package com.java2s; //License from project: Open Source License import java.util.concurrent.TimeUnit; public class Main { public static long convertTo(long a, TimeUnit from, TimeUnit to) { switch (to) { case NANOSECONDS: return from.toNanos(a); case MICROSECONDS: return from.toMicros(a); case MILLISECONDS: return from.toMillis(a); case SECONDS: return from.toSeconds(a); case MINUTES: return from.toMinutes(a); case HOURS: return from.toHours(a); case DAYS: return from.toDays(a); default:/* w ww . j ava 2 s .c o m*/ throw new IllegalArgumentException("TimeUnit \"" + to.toString() + "\" is not supported!"); } } }