Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8069324

Using date format RFC_1123_DATE_TIME throws exception on current time

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 8u25
    • core-libs
    • x86
    • windows_vista

      FULL PRODUCT VERSION :
      java version "1.8.0_25"
      Java(TM) SE Runtime Environment (build 1.8.0_25-b18)
      Java HotSpot(TM) Client VM (build 25.25-b02, mixed mode, sharing)


      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.0.6002]

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Windows Vista Home Premium

      A DESCRIPTION OF THE PROBLEM :
      Sorry, there was no bug category for java.time, so I picked something close.

      This little program:

      class DateTesting {
          public static void main(String[] args) {
              System.out.println(
                      java.time.LocalDateTime.now().format(
                              java.time.format.DateTimeFormatter.
                             RFC_1123_DATE_TIME));
          }
      }

      crashes with:

      C:\misc\misc\sync_newer\python\experiments>java -cp . DateTesting
      Exception in thread "main" java.time.temporal.UnsupportedTemporalTypeException: Unsupported field: OffsetSeconds
              at java.time.LocalDate.get0(LocalDate.java:680)
              at java.time.LocalDate.getLong(LocalDate.java:659)
              at java.time.LocalDateTime.getLong(LocalDateTime.java:720)
              at java.time.format.DateTimePrintContext.getValue(DateTimePrintContext.java:298)
              at java.time.format.DateTimeFormatterBuilder$OffsetIdPrinterParser.format(DateTimeFormatterBuilder.java:3338)
              at java.time.format.DateTimeFormatterBuilder$CompositePrinterParser.format(DateTimeFormatterBuilder.java:2182)
              at java.time.format.DateTimeFormatter.formatTo(DateTimeFormatter.java:1744)
              at java.time.format.DateTimeFormatter.format(DateTimeFormatter.java:1718)
              at java.time.LocalDateTime.format(LocalDateTime.java:1746)
              at DateTesting.main(DateTesting.java:7)

      Using an alternate format enum (ISO_DATE_TIME) works OK.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the program given in "Description".

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Should print formatted date-time.
      ACTUAL -
      Crash



      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Exception in thread "main" java.time.temporal.UnsupportedTemporalTypeException: Unsupported field: OffsetSeconds
              at java.time.LocalDate.get0(LocalDate.java:680)
              at java.time.LocalDate.getLong(LocalDate.java:659)
              at java.time.LocalDateTime.getLong(LocalDateTime.java:720)
              at java.time.format.DateTimePrintContext.getValue(DateTimePrintContext.java:298)
              at java.time.format.DateTimeFormatterBuilder$OffsetIdPrinterParser.format(DateTimeFormatterBuilder.java:3338)
              at java.time.format.DateTimeFormatterBuilder$CompositePrinterParser.format(DateTimeFormatterBuilder.java:2182)
              at java.time.format.DateTimeFormatter.formatTo(DateTimeFormatter.java:1744)
              at java.time.format.DateTimeFormatter.format(DateTimeFormatter.java:1718)
              at java.time.LocalDateTime.format(LocalDateTime.java:1746)
              at DateTesting.main(DateTesting.java:7)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      class DateTesting {
          public static void main(String[] args) {
              System.out.println(
                      java.time.LocalDateTime.now().format(
                              java.time.format.DateTimeFormatter.
                             RFC_1123_DATE_TIME));
          }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Use a different format constant, or a different technique for formatting the date.

            rriggs Roger Riggs
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: