FULL PRODUCT VERSION :
java version "1.6.0_23"
ADDITIONAL OS VERSION INFORMATION :
Windows 7 64-bit
Redhat 5
A DESCRIPTION OF THE PROBLEM :
public static void main(String[] args){
try {
Date birthday = parseDate("1965-03-21 00:00:00", "yyyy-MM-dd HH:mm:ss");
} catch (Exception e) {
e.printStackTrace();
}
}
Result:
java.text.ParseException: Unparseable date: "1965-03-21 00:00:00"
public static Date parseDate(String date, String format) throws Exception{
SimpleDateFormat dateFormat = new SimpleDateFormat(format, locale);
dateFormat.setTimeZone(TimeZone.getTimeZone("Asia/Macau"));
System.out.println("tz="+dateFormat.getTimeZone());
dateFormat.setLenient(false);
if(date != null){
return dateFormat.parse(date);
}else{
return null;
}
}
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Just follow the source code i provided!!
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
parse correctly
ACTUAL -
Unparasable date!!! Even worse, the date after 1965-03-21 will be delayed for 1 day!!!
e.g. Parsing a date "1965-03-22" will return "1965-03-21"!!!
ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.text.ParseException: Unparseable date: "1965-03-21 00:00:00"
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
java.text.ParseException: Unparseable date: "1965-03-21 00:00:00"
public static void main(String[] args){
try {
Date birthday = parseDate("1965-03-21 00:00:00", "yyyy-MM-dd HH:mm:ss");
} catch (Exception e) {
e.printStackTrace();
}
}
Result:
java.text.ParseException: Unparseable date: "1965-03-21 00:00:00"
public static Date parseDate(String date, String format) throws Exception{
SimpleDateFormat dateFormat = new SimpleDateFormat(format, locale);
dateFormat.setTimeZone(TimeZone.getTimeZone("Asia/Macau"));
System.out.println("tz="+dateFormat.getTimeZone());
dateFormat.setLenient(false);
if(date != null){
return dateFormat.parse(date);
}else{
return null;
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Change timezone setting, do not use "Asia/Macau or Asia/Macao"
SUPPORT :
YES
java version "1.6.0_23"
ADDITIONAL OS VERSION INFORMATION :
Windows 7 64-bit
Redhat 5
A DESCRIPTION OF THE PROBLEM :
public static void main(String[] args){
try {
Date birthday = parseDate("1965-03-21 00:00:00", "yyyy-MM-dd HH:mm:ss");
} catch (Exception e) {
e.printStackTrace();
}
}
Result:
java.text.ParseException: Unparseable date: "1965-03-21 00:00:00"
public static Date parseDate(String date, String format) throws Exception{
SimpleDateFormat dateFormat = new SimpleDateFormat(format, locale);
dateFormat.setTimeZone(TimeZone.getTimeZone("Asia/Macau"));
System.out.println("tz="+dateFormat.getTimeZone());
dateFormat.setLenient(false);
if(date != null){
return dateFormat.parse(date);
}else{
return null;
}
}
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Just follow the source code i provided!!
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
parse correctly
ACTUAL -
Unparasable date!!! Even worse, the date after 1965-03-21 will be delayed for 1 day!!!
e.g. Parsing a date "1965-03-22" will return "1965-03-21"!!!
ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.text.ParseException: Unparseable date: "1965-03-21 00:00:00"
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
java.text.ParseException: Unparseable date: "1965-03-21 00:00:00"
public static void main(String[] args){
try {
Date birthday = parseDate("1965-03-21 00:00:00", "yyyy-MM-dd HH:mm:ss");
} catch (Exception e) {
e.printStackTrace();
}
}
Result:
java.text.ParseException: Unparseable date: "1965-03-21 00:00:00"
public static Date parseDate(String date, String format) throws Exception{
SimpleDateFormat dateFormat = new SimpleDateFormat(format, locale);
dateFormat.setTimeZone(TimeZone.getTimeZone("Asia/Macau"));
System.out.println("tz="+dateFormat.getTimeZone());
dateFormat.setLenient(false);
if(date != null){
return dateFormat.parse(date);
}else{
return null;
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Change timezone setting, do not use "Asia/Macau or Asia/Macao"
SUPPORT :
YES