Top Description Fields Constructors Methods
net.sf.ehcache.util

public Class TimeUtil

extends Object
Class Inheritance

Utilities for converting times
Author
Greg Luck

Field Summary

Modifier and TypeField and Description
pack-priv static final long
ONE_SECOND

Constant that contains the amount of milliseconds in a second

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static int

Returns:

Same int value unless long > Integer.MAX_VALUE in which case MAX_VALUE is returned
convertTimeToInt
(long
Long value
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.

public static long

Returns:

The equivalent time in milliseconds
toMillis
(int
the time in seconds
timeInSecs
)

Converts seconds to milliseconds, with a precision of 1 second

public static int

Returns:

The equivalent time in seconds
toSecs
(long timeInMillis)

Converts milliseconds to seconds

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ONE_SECONDback to summary
pack-priv static final long ONE_SECOND

Constant that contains the amount of milliseconds in a second

Constructor Detail

TimeUtilback to summary
public TimeUtil()

Method Detail

convertTimeToIntback to summary
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

Long value

Returns:int

Same int value unless long > Integer.MAX_VALUE in which case MAX_VALUE is returned

toMillisback to summary
public static long toMillis(int timeInSecs)

Converts seconds to milliseconds, with a precision of 1 second

Parameters
timeInSecs:int

the time in seconds

Returns:long

The equivalent time in milliseconds

toSecsback to summary
public static int toSecs(long timeInMillis)

Converts milliseconds to seconds

Returns:int

The equivalent time in seconds