Class DateUtil


  • public class DateUtil
    extends Object
    Contains helper methods to convert between dates in ISO format and LDAP generalized time syntax.

    Examples of ISO-formated dates:

    • 2011-12-03T10:15:30
    • 2011-12-03T10:15:30.4+01:00

    Equivalent dates in generalized time format:

    • 20111203101530.000Z
    • 20111203111530.400Z
    • Method Detail

      • ISOToMillis

        public static Long ISOToMillis​(String strDate)
      • ISOToGeneralizedStringDate

        public static String ISOToGeneralizedStringDate​(String strDate)
        Converts a string representation of a date (expected to follow the pattern of DateTime XML schema data type) to a string representation of a date in LDAP generalized time syntax (see RFC 4517 section 3.3.13).

        xsd:dateTime is equivalent to ISO-8601 format, namely, yyyy-MM-dd'T'HH:mm:ss.SSSZZ

        Parameters:
        strDate - A string date in ISO format.
        Returns:
        A String representing a date in generalized time syntax. If the date passed as parameter did not adhere to xsd:dateTime, the returned value is null
      • generalizedToISOStringDate

        public static String generalizedToISOStringDate​(String strDate)
        Converts a string representing a date (in the LDAP generalized time syntax) to an ISO-8601 formatted string date.
        Parameters:
        strDate - A string date in generalized time syntax (see RFC 4517 section 3.3.13)
        Returns:
        A string representation of a date in ISO format. If the date passed as parameter did not adhere to generalized time syntax, null is returned.
      • millisToISOString

        public static String millisToISOString​(long millis)
        Returns a string representation of a date in ISO format based on a number of milliseconds elapsed from "the epoch", namely January 1, 1970, 00:00:00 GMT.
        Parameters:
        millis - Number of milliseconds
        Returns:
        An ISO-formatted string date
      • gluuCouchbaseISODate

        public static String gluuCouchbaseISODate​(String value)
        Takes an ISO date and converts to one in UTC+0 time zone (but he timezone suffix/offset is supressed in the result)
        Parameters:
        value - A string representing a date in ISO-8601, eg 2007-12-03T10:15:30+01:00
        Returns:
        A string representing the same input date (eg 2007-12-03T09:15:30)