1
SimpleDateFormat formatObject = new SimpleDateFormat("yyyy-MM-dd");   
String attrValue="2015-09-24";   
Date date = ((SimpleDateFormat) formatObject).parse(attrValue);    
java.sql.Date parsedValue = new java.sql.Date(date.getTime());    

randomly some time it prints parsedValue 1970-09-24 sets year to 1970 instead of 2015, if parse again same it parse correctly to 2015-09-24 not getting reason why some time parse sets year to 1970. We are using jdk1.4

1 Answers1

0

Try DateFormat.setLenient(false); and watch out whether the issue is in java.util.Date or java.sql.Date.

Chethan C
  • 54
  • 7