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

SimpleDateFormat parse bug

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 7u65
    • core-libs
    • x86
    • windows_7

      FULL PRODUCT VERSION :
      java version "1.7.0_65"
      Java(TM) SE Runtime Environment (build 1.7.0_65-b20)
      Java HotSpot(TM) Client VM (build 24.65-b04, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Windows 7 32-bit SP1

      A DESCRIPTION OF THE PROBLEM :
      I tried to use the parse method in the SimpleDateFormat class withe value of '2014-15-45' there is no exception throw, but return as follows,

      C:\terry>java TestDate 2014-15-45
      Tue Apr 14 00:00:00 CST 2015

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      I tried to use the parse method in the SimpleDateFormat class withe value of '2014-15-45' there is no exception throw, but return as follows,

      C:\terry>java TestDate 2014-15-45
      Tue Apr 14 00:00:00 CST 2015

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      throw exception
      ACTUAL -
      Tue Apr 14 00:00:00 CST 2015

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.text.*;

      public class TestDate {
      public static void main(String[] args) throws Exception {
      SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
      System.out.println(sdf.parse(args[0]).toString());
      }
      }
      ---------- END SOURCE ----------

      SUPPORT :
      YES

            okutsu Masayoshi Okutsu
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: