Package org.keycloak.common.util
Class Time
java.lang.Object
org.keycloak.common.util.Time
- Author:
- Stian Thorgersen
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intDeprecated.static longReturns current time in milliseconds adjusted by addingoffsetseconds.static longReturns current time in seconds adjusted by addingoffsetseconds.static intstatic voidsetOffset(int offset) Sets time offset in seconds that will be added tocurrentTime()andcurrentTimeMillis().static DatetoDate(int time) ReturnsDateobject, its value set to timestatic DatetoDate(long time) ReturnsDateobject, its value set to timestatic longtoMillis(long time) Returns time in milliseconds for a time in seconds.
-
Constructor Details
-
Time
public Time()
-
-
Method Details
-
currentTime
Deprecated.UsecurrentTimeSeconds()to avoid integer overflow beyond year 2038.Returns current time in seconds adjusted by addingoffsetseconds.- Returns:
- see description
-
currentTimeSeconds
public static long currentTimeSeconds()Returns current time in seconds adjusted by addingoffsetseconds. UnlikecurrentTime(), this method returns alongto avoid integer overflow beyond year 2038.- Returns:
- see description
-
currentTimeMillis
public static long currentTimeMillis()Returns current time in milliseconds adjusted by addingoffsetseconds.- Returns:
- see description
-
toDate
ReturnsDateobject, its value set to time- Parameters:
time- Time in milliseconds since the epoch- Returns:
- see description
-
toDate
ReturnsDateobject, its value set to time- Parameters:
time- Time in milliseconds since the epoch- Returns:
- see description
-
toMillis
public static long toMillis(long time) Returns time in milliseconds for a time in seconds. No adjustment is made to the parameter.- Parameters:
time- Time in seconds since the epoch- Returns:
- Time in milliseconds
-
getOffset
public static int getOffset()- Returns:
- Time offset in seconds that will be added to
currentTime()andcurrentTimeMillis().
-
setOffset
public static void setOffset(int offset) Sets time offset in seconds that will be added tocurrentTime()andcurrentTimeMillis().- Parameters:
offset- Offset (in seconds)
-
currentTimeSeconds()to avoid integer overflow beyond year 2038.