I have a String which contains date string eg 12-28-18 of format MM-dd-yy. I wish to pass this parameter to a stored procedure in Oracle database.
Hence, I am trying to convert this String to java.sql.Date. Following is the method I am following to convert:
DateFormat df = new SimpleDateFormat("MM-dd-yy");
java.util.Date date1 = df.parse(valueobject.getDate());
java.sql.Date date2 = new java.sql.Date(date1.getTime())
However , it leads to ParseException.
Not able to figure out why it fails during parsing.
Any help on this would be great!
new SimpleDateFormat("MM-dd-yy", Locale.English);?new SimpleDateFormat("MM-dd-yy", Locale.ENGLISH).parse("12-28-18");but no exception thrown.valueobject.getDate()a String? Just to double check. I've seen someone accidentally try to parse a date into a date.