Package org.forgerock.opendj.ldap
Class GeneralizedTime
java.lang.Object
org.forgerock.opendj.ldap.GeneralizedTime
- All Implemented Interfaces:
Comparable<GeneralizedTime>
An LDAP generalized time as defined in RFC 4517. This class facilitates
parsing of generalized time values to and from
Date and
Calendar classes.
The following are examples of generalized time values:
199412161032Z 199412160532-0500
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final GeneralizedTimeThe smallest time representable using the generalized time syntax.static final longThe smallest time in milli-seconds representable using the generalized time syntax. -
Method Summary
Modifier and TypeMethodDescriptionintstatic GeneralizedTimeReturns a generalized time whose value is the current time, using the default time zone and locale.booleanlongReturns the value of this generalized time in milliseconds since the epoch.inthashCode()Returns aCalendarrepresentation of this generalized time.toDate()Returns aDaterepresentation of this generalized time.Returns aOffsetDateTimerepresentation of this generalized time.toString()static GeneralizedTimevalueOf(long timeMS) Returns a generalized time representing the provided time in milliseconds since the epoch.static GeneralizedTimeParses the provided string as an LDAP generalized time.static GeneralizedTimevalueOf(TemporalAccessor temporal) Returns a generalized time representing the providedTemporalAccessor.static GeneralizedTimeReturns a generalized time representing the providedCalendar.static GeneralizedTimeReturns a generalized time representing the providedDate.
-
Field Details
-
MIN_GENERALIZED_TIME
The smallest time representable using the generalized time syntax. -
MIN_GENERALIZED_TIME_MS
The smallest time in milli-seconds representable using the generalized time syntax.
-
-
Method Details
-
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
Returns a generalized time representing the providedCalendar.The provided calendar will be defensively copied in order to preserve immutability.
- Parameters:
calendar- The calendar to be converted to a generalized time.- Returns:
- A generalized time representing the provided
Calendar.
-
valueOf
Returns a generalized time representing the providedDate.The provided date will be defensively copied in order to preserve immutability.
- Parameters:
date- The date to be converted to a generalized time.- Returns:
- A generalized time representing the provided
Date.
-
valueOf
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
Returns a generalized time representing the providedTemporalAccessor.- Parameters:
temporal- The temporal accessor to be converted to a generalized time.- Returns:
- A generalized time representing the provided
TemporalAccessor. - Throws:
DateTimeException- If the temporal accessor cannot be converted to anInstant.NullPointerException- Iftemporalwasnull.
-
valueOf
Parses the provided string as an LDAP generalized time.- Parameters:
time- The generalized time value to be parsed.- Returns:
- The parsed generalized time.
- Throws:
org.forgerock.i18n.LocalizedIllegalArgumentException- Iftimecannot be parsed as a valid generalized time string.NullPointerException- Iftimewasnull.
-
compareTo
- Specified by:
compareToin interfaceComparable<GeneralizedTime>
-
equals
-
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.
-
hashCode
-
toCalendar
Returns aCalendarrepresentation of this generalized time.Subsequent modifications to the returned calendar will not alter the internal state of this generalized time.
- Returns:
- A
Calendarrepresentation of this generalized time.
-
toDate
Returns aDaterepresentation of this generalized time.Subsequent modifications to the returned date will not alter the internal state of this generalized time.
- Returns:
- A
Daterepresentation of this generalized time.
-
toOffsetDateTime
Returns aOffsetDateTimerepresentation of this generalized time.- Returns:
- A
OffsetDateTimerepresentation of this generalized time.
-
toString
-