Class DateUtil

java.lang.Object
org.apache.mina.http.DateUtil

public class DateUtil extends Object
An utility class for Dates manipulations
  • Field Details

    • LOCALE

      private static final Locale LOCALE
    • GMT_ZONE

      private static final TimeZone GMT_ZONE
    • RFC_1123_PATTERN

      private static final String RFC_1123_PATTERN
      See Also:
    • RFC_1123_FORMAT

      private static final DateFormat RFC_1123_FORMAT
    • DIGIT_PATTERN

      private static final Pattern DIGIT_PATTERN
      Pattern to find digits only.
  • Constructor Details

    • DateUtil

      private DateUtil()
  • Method Details

    • getCurrentAsString

      public static String getCurrentAsString()
      Returns:
      The current date as a string
    • parseDateStringToMilliseconds

      private static long parseDateStringToMilliseconds(String dateString)
      Translate a given date String in the RFC 1123 format to a long representing the number of milliseconds since epoch.
      Parameters:
      dateString - a date String in the RFC 1123 format.
      Returns:
      the parsed Date in milliseconds.
    • parseToMilliseconds

      public static long parseToMilliseconds(String dateValue)
      Parse a given date String to a long representation of the time. Where the provided value is all digits the value is returned as a long, otherwise attempt is made to parse the String as a RFC 1123 date.
      Parameters:
      dateValue - the value to parse.
      Returns:
      the long value following parse, or zero where not successful.
    • parseToRFC1123

      public static String parseToRFC1123(long dateValue)
      Converts a millisecond representation of a date to a RFC 1123 formatted String.
      Parameters:
      dateValue - the Date represented as milliseconds.
      Returns:
      a String representation of the date.
    • getDateAsString

      public static String getDateAsString(Date date)
      Convert a given Date object to a RFC 1123 formatted String.
      Parameters:
      date - the Date object to convert
      Returns:
      a String representation of the date.