I wrote a method to parse a date. When I'm passing the following date as an argument 2019-03-05 06:15:00
, I'm getting a java.text.ParseException: Unparseable date: "2019-03-05 06:15:00"
.
What could be wrong with the logic?
public String convertDate(String val) throws ParseException {
return "cast('" + new SimpleDateFormat("yyyy-MM-dd HH:mm:SS").format(
new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'").parse(val)) + "' as ts)";
}