java.lang.Object
net.i2p.router.news.RFC3339Date

public abstract class RFC3339Dateextends Object
RFC 3339 date parsing utility for Atom feed compatibility.

Provides parsing and formatting of dates according to RFC 3339 (ISO 8601) and RFC 4287 Atom specifications. Supports multiple date formats including timezone handling and millisecond precision.

Adapted from RFC822Date with enhanced support for modern date formats and timezone specifications. Handles both numeric and named timezone offsets with proper validation.

Thread-safe implementation with ThreadLocal formatters for concurrent access. Includes comprehensive format support for various date representations encountered in news feeds.

See Also:
  • Field Details

    • TZF1

      private static final String TZF1
      First timezone format accepted when parsing.
    • TZF2

      private static final String TZF2
      Second timezone format accepted when parsing.
    • OUTPUT_FORMAT

      private static final ThreadLocal<DateFormat> OUTPUT_FORMAT
      Formatter writing an RFC 3339 date.
    • DATE_FORMATS

      private static final ThreadLocal<DateFormat[]> DATE_FORMATS
      Formatters tried when parsing a date.
  • Constructor Details

    • RFC3339Date

      public RFC3339Date()
      Constructor for subclasses; the parser and formatter in this base class are static.
  • Method Details

    • parse3339Date

      public static long parse3339Date(String s)
      Parse the date.
      Parameters:
      s - non-null
      Returns:
      -1 on failure
    • to3339Date

      public static String to3339Date(long t)
      Format is "yyyy-MM-ddTHH:mm:ssZ".
      Parameters:
      t - milliseconds since the epoch to render, always formatted in GMT
      Returns:
      the instant rendered as yyyy-MM-ddTHH:mm:ssZ with a literal Z