Package org.forgerock.opendj.ldap
Class GeneralizedTime
- java.lang.Object
-
- org.forgerock.opendj.ldap.GeneralizedTime
-
- All Implemented Interfaces:
Comparable<GeneralizedTime>
public final class GeneralizedTime extends Object implements Comparable<GeneralizedTime>
-
-
Field Summary
Fields Modifier and Type Field Description static GeneralizedTime
MIN_GENERALIZED_TIME
The smallest time representable using the generalized time syntax.static long
MIN_GENERALIZED_TIME_MS
The smallest time in milli-seconds representable using the generalized time syntax.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(GeneralizedTime o)
static GeneralizedTime
currentTime()
Returns a generalized time whose value is the current time, using the default time zone and locale.boolean
equals(Object obj)
long
getTimeInMillis()
Returns the value of this generalized time in milliseconds since the epoch.int
hashCode()
Calendar
toCalendar()
Returns aCalendar
representation of this generalized time.OffsetDateTime
toOffsetDateTime()
Returns aOffsetDateTime
representation of this generalized time.String
toString()
static GeneralizedTime
valueOf(long timeMS)
Returns a generalized time representing the provided time in milliseconds since the epoch.static GeneralizedTime
valueOf(String time)
Parses the provided string as an LDAP generalized time.static GeneralizedTime
valueOf(Instant instant)
Returns a generalized time representing the provided instant in milliseconds since the epoch.static GeneralizedTime
valueOf(OffsetDateTime offsetDateTime)
Returns a generalized time representing the providedOffsetDateTime
.static GeneralizedTime
valueOf(Calendar calendar)
Returns a generalized time representing the providedCalendar
.static GeneralizedTime
valueOf(Date date)
Returns a generalized time representing the providedDate
.
-
-
-
Field Detail
-
MIN_GENERALIZED_TIME
public static final GeneralizedTime MIN_GENERALIZED_TIME
The smallest time representable using the generalized time syntax.
-
MIN_GENERALIZED_TIME_MS
public static final long MIN_GENERALIZED_TIME_MS
The smallest time in milli-seconds representable using the generalized time syntax.
-
-
Method Detail
-
currentTime
public static GeneralizedTime currentTime()
Returns a generalized time whose value is the current time, using the default time zone and locale.- Returns:
- A generalized time whose value is the current time.
-
valueOf
public static GeneralizedTime valueOf(Calendar calendar)
Returns a generalized time representing the providedCalendar
.- Parameters:
calendar
- The calendar to be converted to a generalized time.- Returns:
- A generalized time representing the provided
Calendar
.
-
valueOf
public static GeneralizedTime valueOf(Date date)
Returns a generalized time representing the providedDate
.- Parameters:
date
- The date to be converted to a generalized time.- Returns:
- A generalized time representing the provided
Date
.
-
valueOf
public static GeneralizedTime valueOf(long timeMS)
Returns a generalized time representing the provided time in milliseconds since the epoch.- Parameters:
timeMS
- The time to be converted to a generalized time.- Returns:
- A generalized time representing the provided time in milliseconds since the epoch.
-
valueOf
public static GeneralizedTime valueOf(Instant instant)
Returns a generalized time representing the provided instant in milliseconds since the epoch.- Parameters:
instant
- The instant to be converted to a generalized time.- Returns:
- A generalized time representing the provided instant in milliseconds since the epoch.
-
valueOf
public static GeneralizedTime valueOf(String time)
Parses the provided string as an LDAP generalized time.- Parameters:
time
- The generalized time value to be parsed.- Returns:
- The parsed generalized time.
- Throws:
LocalizedIllegalArgumentException
- Iftime
cannot be parsed as a valid generalized time string.NullPointerException
- Iftime
wasnull
.
-
valueOf
public static GeneralizedTime valueOf(OffsetDateTime offsetDateTime)
Returns a generalized time representing the providedOffsetDateTime
.- Parameters:
offsetDateTime
- TheOffsetDateTime
to be converted to a generalized time.- Returns:
- A generalized time representing the provided
OffsetDateTime
. - See Also:
toOffsetDateTime()
-
getTimeInMillis
public long getTimeInMillis()
Returns the value of this generalized time in milliseconds since the epoch.- Returns:
- The value of this generalized time in milliseconds since the epoch.
-
toOffsetDateTime
public OffsetDateTime toOffsetDateTime()
Returns aOffsetDateTime
representation of this generalized time.- Returns:
- A
OffsetDateTime
representation of this generalized time. - See Also:
valueOf(OffsetDateTime)
-
toCalendar
public Calendar toCalendar()
Returns aCalendar
representation of this generalized time.Subsequent modifications to the returned calendar will not alter the internal state of this generalized time.
- Returns:
- A
Calendar
representation of this generalized time.
-
compareTo
public int compareTo(GeneralizedTime o)
- Specified by:
compareTo
in interfaceComparable<GeneralizedTime>
-
-