FULL PRODUCT VERSION :
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b112)
Java HotSpot(TM) 64-Bit Server VM (build 20.0-b01, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
MS Windows 6.1.7601
A DESCRIPTION OF THE PROBLEM :
SimpleDateFormat doesn't throw exception, where it should, instead of this giver wrong results
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Runt test case
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Exception in thread "main" java.lang.IllegalArgumentException: Illegal pattern character 'Y'
at java.text.SimpleDateFormat.compile(SimpleDateFormat.java:769)
at java.text.SimpleDateFormat.initialize(SimpleDateFormat.java:576)
at java.text.SimpleDateFormat.<init>(SimpleDateFormat.java:501)
at java.text.SimpleDateFormat.<init>(SimpleDateFormat.java:476)
at test.TestCal.main(TestCal.java:15)
ACTUAL -
Mon Dec 31 00:00:00 CET 2012
Mon Dec 31 00:00:00 CET 2012
Mon Dec 31 00:00:00 CET 2012
Mon Dec 31 00:00:00 CET 2012
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package test;
import java.text.ParseException;
import java.text.SimpleDateFormat;
public class TestCal {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
SimpleDateFormat sdf = new SimpleDateFormat("YYYY-MM-DD");
String bal = "2013-01-01";
String test2 = "2013-03-03";
try {
System.out.println(sdf.parse(bal).toString());
System.out.println(sdf.parse("2013-01-01").toString());
System.out.println(sdf.parse(test2).toString());
System.out.println(sdf.parse("2013-03-03").toString());
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
not possible
SUPPORT :
YES
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b112)
Java HotSpot(TM) 64-Bit Server VM (build 20.0-b01, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
MS Windows 6.1.7601
A DESCRIPTION OF THE PROBLEM :
SimpleDateFormat doesn't throw exception, where it should, instead of this giver wrong results
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Runt test case
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Exception in thread "main" java.lang.IllegalArgumentException: Illegal pattern character 'Y'
at java.text.SimpleDateFormat.compile(SimpleDateFormat.java:769)
at java.text.SimpleDateFormat.initialize(SimpleDateFormat.java:576)
at java.text.SimpleDateFormat.<init>(SimpleDateFormat.java:501)
at java.text.SimpleDateFormat.<init>(SimpleDateFormat.java:476)
at test.TestCal.main(TestCal.java:15)
ACTUAL -
Mon Dec 31 00:00:00 CET 2012
Mon Dec 31 00:00:00 CET 2012
Mon Dec 31 00:00:00 CET 2012
Mon Dec 31 00:00:00 CET 2012
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package test;
import java.text.ParseException;
import java.text.SimpleDateFormat;
public class TestCal {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
SimpleDateFormat sdf = new SimpleDateFormat("YYYY-MM-DD");
String bal = "2013-01-01";
String test2 = "2013-03-03";
try {
System.out.println(sdf.parse(bal).toString());
System.out.println(sdf.parse("2013-01-01").toString());
System.out.println(sdf.parse(test2).toString());
System.out.println(sdf.parse("2013-03-03").toString());
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
not possible
SUPPORT :
YES
- relates to
-
JDK-4267450 (cal) API: Need public API to calculate, format and parse "year of week"
-
- Closed
-