Class HttpDateTimeFormatter


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

      • HttpDateTimeFormatter

        public HttpDateTimeFormatter()
    • Method Detail

      • parseImfFixedDate

        public static long parseImfFixedDate​(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​(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​(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​(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 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 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 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 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