Class HttpDateTimeFormatter


  • public class HttpDateTimeFormatter
    extends java.lang.Object
    Parsers and Serializers for HTTP dates (RFC 7231, Section 7.1.1.1), using DateTimeFormatter (from Java 8).
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String format​(long millisSinceEpoch)
      Format as HTTP default date (IMF-fixdate) (see RFC 7231, Section 7.1.1.1)
      static java.lang.String formatAscTime​(long millisSinceEpoch)
      Format as HTTP "asctime-date" (see RFC 7231, Section 7.1.1.1)
      static java.lang.String formatImfFixed​(long millisSinceEpoch)
      Format as HTTP "IMF-fixdate" (see RFC 7231, Section 7.1.1.1)
      static java.lang.String formatRfc850​(long millisSinceEpoch)
      Format as HTTP "rfc850-date" (see RFC 7231, Section 7.1.1.1)
      static long parse​(java.lang.String fieldValue)
      Parse HTTP format, trying the three allowable formats defined in RFC 7231, Section 7.1.1.1
      static long parseAscTimeDate​(java.lang.String fieldValue)
      Parse HTTP "asctime-date" format (see RFC 7231, Section 7.1.1.1)
      static long parseImfFixedDate​(java.lang.String fieldValue)
      Parse HTTP "IMF-fixdate" format (see RFC 7231, Section 7.1.1.1)
      static long parseRfc850Date​(java.lang.String fieldValue)
      Parse HTTP "rfc850-date" format (see RFC 7231, Section 7.1.1.1)
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • HttpDateTimeFormatter

        public HttpDateTimeFormatter()
    • Method Detail

      • parseImfFixedDate

        public static long parseImfFixedDate​(java.lang.String fieldValue)
        Parse HTTP "IMF-fixdate" format (see RFC 7231, Section 7.1.1.1)
        Parameters:
        fieldValue - string value
        Returns:
        ms since epoch throws DateTimeParseException on invalid input
      • parseRfc850Date

        public static long parseRfc850Date​(java.lang.String fieldValue)
        Parse HTTP "rfc850-date" format (see RFC 7231, Section 7.1.1.1)
        Parameters:
        fieldValue - string value
        Returns:
        ms since epoch throws DateTimeParseException on invalid input
      • parseAscTimeDate

        public static long parseAscTimeDate​(java.lang.String fieldValue)
        Parse HTTP "asctime-date" format (see RFC 7231, Section 7.1.1.1)
        Parameters:
        fieldValue - string value
        Returns:
        ms since epoch throws DateTimeParseException on invalid input
      • parse

        public static long parse​(java.lang.String fieldValue)
        Parse HTTP format, trying the three allowable formats defined in RFC 7231, Section 7.1.1.1
        Parameters:
        fieldValue - string value
        Returns:
        ms since epoch throws DateTimeParseException on invalid input
      • format

        public static java.lang.String format​(long millisSinceEpoch)
        Format as HTTP default date (IMF-fixdate) (see RFC 7231, Section 7.1.1.1)
        Parameters:
        millisSinceEpoch - ms since epoch
        Returns:
        string representation
      • formatImfFixed

        public static java.lang.String formatImfFixed​(long millisSinceEpoch)
        Format as HTTP "IMF-fixdate" (see RFC 7231, Section 7.1.1.1)
        Parameters:
        millisSinceEpoch - ms since epoch
        Returns:
        string representation
      • formatRfc850

        public static java.lang.String formatRfc850​(long millisSinceEpoch)
        Format as HTTP "rfc850-date" (see RFC 7231, Section 7.1.1.1)
        Parameters:
        millisSinceEpoch - ms since epoch
        Returns:
        string representation
      • formatAscTime

        public static java.lang.String formatAscTime​(long millisSinceEpoch)
        Format as HTTP "asctime-date" (see RFC 7231, Section 7.1.1.1)
        Parameters:
        millisSinceEpoch - ms since epoch
        Returns:
        string representation