I want to parse a String into a SQL DateTime. The string is the result of the concatenation of a SQL Date and a String that contains the time with the following format: HH:MM.
My code:
try {
java.util.Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(beanActividad.getFecha().toString() + " " + beanActividad.getHora() + ":00");
datetime = new java.sql.Timestamp(date.getTime());
} catch (ParseException ex) {
Logger.getLogger(ActividadesBackingBean.class.getName()).log(Level.SEVERE, null, ex);
}
beanActividad.getHora()
gets the hour String part, beanActividad.getFecha().toString()
the java util Date part and finally it all concatenates with ":00", so it has a SQL DateTime properly syntax.
The error:
java.text.ParseException: Unparseable date: "Tue May 26 00:00:00 CEST 2020 12:00:00"
What i want is to get a TimeStamp, so I can load it into the database as a SQL DateTime.