Class DateUtils

java.lang.Object
org.restlet.engine.util.DateUtils

public final class DateUtils extends Object
Date manipulation utilities.
Author:
Jerome Louvel
  • Field Details

    • FORMAT_ASC_TIME

      public static final List<String> FORMAT_ASC_TIME
      Obsoleted HTTP date format (ANSI C asctime() format). Pattern: "EEE MMM dd HH:mm:ss yyyy".
    • FORMAT_RFC_1036

      public static final List<String> FORMAT_RFC_1036
      Obsoleted HTTP date format (RFC 1036). Pattern: "EEEE, dd-MMM-yy HH:mm:ss zzz".
    • FORMAT_RFC_1123

      public static final List<String> FORMAT_RFC_1123
      Preferred HTTP date format (RFC 1123). Pattern: "EEE, dd MMM yyyy HH:mm:ss zzz".
    • FORMAT_RFC_3339

      public static final List<String> FORMAT_RFC_3339
      W3C date format (RFC 3339). Pattern: "yyyy-MM-dd'T'HH:mm:ssz".
    • FORMAT_ISO_8601

      public static final List<String> FORMAT_ISO_8601
      AWS date format (ISO 8601). Pattern: "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'".
    • FORMAT_RFC_822

      public static final List<String> FORMAT_RFC_822
      Common date format (RFC 822). Patterns: "EEE, dd MMM yy HH:mm:ss z" or "EEE, dd MMM yy HH:mm z", "dd MMM yy HH:mm:ss z" or "dd MMM yy HH:mm z".
  • Method Details

    • after

      public static boolean after(Date baseDate, Date afterDate)
      Compares two date with a precision of one second.
      Parameters:
      baseDate - The base date
      afterDate - The date supposed to be after.
      Returns:
      True if the afterDate is indeed after the baseDate.
    • before

      public static boolean before(Date baseDate, Date beforeDate)
      Compares two date with a precision of one second.
      Parameters:
      baseDate - The base date
      beforeDate - The date supposed to be before.
      Returns:
      True if the beforeDate is indeed before the baseDate.
    • equals

      public static boolean equals(Date baseDate, Date otherDate)
      Compares two date with a precision of one second.
      Parameters:
      baseDate - The base date
      otherDate - The other date supposed to be equals.
      Returns:
      True if both dates are equals.
    • format

      public static String format(Date date)
      Formats a Date in the default HTTP format (RFC 1123).
      Parameters:
      date - The date to format.
      Returns:
      The formatted date.
    • format

      public static String format(Date date, List<String> formats)
      Formats a Date according to the first format in the array.
      Parameters:
      date - The date to format.
      formats - The array of date formats to use.
      Returns:
      The formatted date.
    • format

      public static String format(Date date, String format)
      Formats a Date according to the given format.
      Parameters:
      date - The date to format.
      format - The date format to use.
      Returns:
      The formatted date.
    • parse

      public static Date parse(String date)
      Parses a formatted date into a Date object using the default HTTP format (RFC 1123).
      Parameters:
      date - The date to parse.
      Returns:
      The parsed date.
    • parse

      public static Date parse(String date, List<String> formats)
      Parses a formatted date into a Date object.
      Parameters:
      date - The date to parse.
      formats - The date formats to use sorted by completeness.
      Returns:
      The parsed date.
    • unmodifiable

      public static Date unmodifiable(Date date)
      Returns an immutable version of a given date.
      Parameters:
      date - The modifiable date.
      Returns:
      An immutable version of a given date.