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

DateFormat.parse() returning wrong date for Julian format "yDDD"

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 6u43
    • core-libs

      FULL PRODUCT VERSION :
      java version "1.6.0_43"
      Java(TM) SE Runtime Environment (build 1.6.0_43-b01)
      Java HotSpot(TM) 64-Bit Server VM (build 20.14-b01, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Linux localhost.localdomain 3.4.9-2.fc16.x86_64 #1 SMP Thu Aug 23 17:51:29 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

      A DESCRIPTION OF THE PROBLEM :
      using the DateFormat.parse method to parse dates referring to the same day as the source in the different formats returns a two different Dates
      for SimpleDateFormart("MMddyy").parse("082713")
      expected <Tue Aug 06 00:00:00 CAT 2013> but was:<Mon Aug 06 00:00:00 CAT 2013>

      for SimpleDateFormart("MMddyy").parse("3239")
      expected <Tue Aug 06 00:00:00 CAT 2013> but was <Tue Aug 06 00:00:00 CAT 3>


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      compare two of the same dates made with these two formarts

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      for SimpleDateFormart("MMddyy").parse("3239")
      expected <Tue Aug 06 00:00:00 CAT 2013>
      ACTUAL -
      for SimpleDateFormart("MMddyy").parse("3239")
      expected <Tue Aug 06 00:00:00 CAT 2013> but was <Tue Aug 06 00:00:00 CAT 3>

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      if((new java.text.SimpleDateFormat("MMddyy").parse("082713")).equals((new java.text.SimpleDateFormat("yDDD").parse("3239")))){
          System.out.println(new java.text.SimpleDateFormat("MMddyy")+" == "+new java.text.SimpleDateFormat("yDDD"));
      }else
      {
          System.out.println((new java.text.SimpleDateFormat("MMddyy").parse("082713"))+" != "+(new java.text.SimpleDateFormat("yDDD").parse("3239")));
      }
      ---------- END SOURCE ----------

            okutsu Masayoshi Okutsu
            naoto Naoto Sato
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: