Package net.sf.ehcache.util
Class TimeUtil
- java.lang.Object
-
- net.sf.ehcache.util.TimeUtil
-
public class TimeUtil extends java.lang.ObjectUtilities for converting times- Author:
- Greg Luck
-
-
Constructor Summary
Constructors Constructor Description TimeUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intconvertTimeToInt(long seconds)Converts a long seconds value to an int seconds value and takes into account overflow from the downcast by switching to Integer.MAX_VALUE.static longtoMillis(int timeInSecs)Converts seconds to milliseconds, with a precision of 1 secondstatic inttoSecs(long timeInMillis)Converts milliseconds to seconds
-
-
-
Method Detail
-
toSecs
public static int toSecs(long timeInMillis)
Converts milliseconds to seconds- Parameters:
timeInMillis-- Returns:
- The equivalent time in seconds
-
toMillis
public static long toMillis(int timeInSecs)
Converts seconds to milliseconds, with a precision of 1 second- Parameters:
timeInSecs- the time in seconds- Returns:
- The equivalent time in milliseconds
-
convertTimeToInt
public static int convertTimeToInt(long seconds)
Converts a long seconds value to an int seconds value and takes into account overflow from the downcast by switching to Integer.MAX_VALUE.- Parameters:
seconds- Long value- Returns:
- Same int value unless long
>Integer.MAX_VALUE in which case MAX_VALUE is returned
-
-