Class GeneralizedTime

java.lang.Object
org.forgerock.opendj.ldap.GeneralizedTime
All Implemented Interfaces:
Comparable<GeneralizedTime>

public final class GeneralizedTime extends Object implements 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 Details

    • 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 Details

    • 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 provided Calendar.

      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

      public static GeneralizedTime valueOf(Date date)
      Returns a generalized time representing the provided Date.

      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

      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(TemporalAccessor temporal)
      Returns a generalized time representing the provided TemporalAccessor.
      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 an Instant.
      NullPointerException - If temporal was null.
    • 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:
      org.forgerock.i18n.LocalizedIllegalArgumentException - If time cannot be parsed as a valid generalized time string.
      NullPointerException - If time was null.
    • compareTo

      public int compareTo(GeneralizedTime o)
      Specified by:
      compareTo in interface Comparable<GeneralizedTime>
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • 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.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toCalendar

      public Calendar toCalendar()
      Returns a Calendar 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.
    • toDate

      public Date toDate()
      Returns a Date representation of this generalized time.

      Subsequent modifications to the returned date will not alter the internal state of this generalized time.

      Returns:
      A Date representation of this generalized time.
    • toOffsetDateTime

      Returns a OffsetDateTime representation of this generalized time.
      Returns:
      A OffsetDateTime representation of this generalized time.
    • toString

      public String toString()
      Overrides:
      toString in class Object