Here you can find the source of convertToSecond(int interval, TimeUnit unit)
public static int convertToSecond(int interval, TimeUnit unit) throws UnsupportedDataTypeException
//package com.java2s; //License from project: Open Source License import java.util.concurrent.TimeUnit; import javax.activation.UnsupportedDataTypeException; import org.joda.time.DateTimeConstants; public class Main { public static int convertToSecond(int interval, TimeUnit unit) throws UnsupportedDataTypeException { switch (unit) { case DAYS: return interval * DateTimeConstants.SECONDS_PER_DAY; case HOURS: return interval * DateTimeConstants.SECONDS_PER_HOUR; case MINUTES: return interval * DateTimeConstants.SECONDS_PER_MINUTE; case SECONDS: return interval; case MILLISECONDS: return interval / DateTimeConstants.MILLIS_PER_SECOND; default://from ww w.j a v a2s. c o m break; } throw new UnsupportedDataTypeException(); } }