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

Date formatting is incorrect since JDK 11

XMLWordPrintable

      ADDITIONAL SYSTEM INFORMATION :
      The other item that has recently changed is that this code is now running on Windows 10 1809 whereas the JDK-10 run was on Windows 10 1803. (In the case the change is because of Windows and not because of JDK-11.)

      A DESCRIPTION OF THE PROBLEM :
      I have not changed (nor recompiled) my code (these class files were probably compiled with JDK-9), here is a date formatted from JDK-10 and before (was the same all the way back to 8) and a similar date as formatted in JDK-11. Note the extra period after Oct
      JDK-10.0.2: (started 18.Sep.19-08.30.44)
      JDK-11: (started 18.Oct..04-14.59.47)

      Sample lines of code doing the formatting are:
      private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yy.MMM.dd-HH.mm.ss");
      writer.write("Date: " + dateFormat.format(new Date()) );

      REGRESSION : Last worked in version 10.0.2

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run program with the supplied lines of code.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      There would not be an extra period in the output.
      So it might look like (started 18.Oct.04-14.59.47)
      ACTUAL -
      There is an extra period in the output:
      (started 18.Oct..04-14.59.47)

      ---------- BEGIN SOURCE ----------
      private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yy.MMM.dd-HH.mm.ss");
      writer.write("Date: " + dateFormat.format(new Date()) );
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      None yet explored... unwilling to second guess the output format of a system library.

      FREQUENCY : always


            psonal Pallavi Sonal (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: