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

XMLFormatter.format emits incorrect year

    XMLWordPrintable

Details

    • b103
    • b119
    • linux_ubuntu
    • Verified

    Description

      FULL PRODUCT VERSION :
      java version "1.8.0-ea"
      Java(TM) SE Runtime Environment (build 1.8.0-ea-b113)

      A DESCRIPTION OF THE PROBLEM :
      This a regression caused by this revision:
      http://hg.openjdk.java.net/jdk8/tl/jdk/rev/c1f129f62f36

      The problematic patch is:

      - sb.append(date.getYear() + 1900);
      + sb.append(cal.get(Calendar.YEAR) + 1900);

      Calendar.YEAR field is already in four-digit format and don't need +1900.

      REGRESSION. Last worked in version 7u45

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      <record>
        <date>2013-11-11T13:32:17</date>
      (...)
      </record>
      ACTUAL -
      <record>
        <date>3913-11-11T13:32:17</date>
      (...)
      </record>

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      // Quick Nashorn script test to run with bin/jjs:

      var simpleFormatter = new java.util.logging.SimpleFormatter();
      var xmlFormatter = new java.util.logging.XMLFormatter();

      var logRecord = new java.util.logging.LogRecord(
      java.util.logging.Level.SEVERE,
      "Test"
      );

      var out = java.lang.System.out;
      out.println(simpleFormatter.format(logRecord)); // good year
      out.println(xmlFormatter.format(logRecord)); // wrong year
      ---------- END SOURCE ----------

      Attachments

        Issue Links

          Activity

            People

              dfuchs Daniel Fuchs
              alanb Alan Bateman
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: