I am trying to parse a string to a date, but the result does not look right: Below is my code.
public static void main(String[] args){ Date startDate = new Date(); DateFormat formatter = new SimpleDateFormat("dd.MM.yyyy hh:mm:ss"); try { startDate = (Date) formatter.parse("07.10.2012 12:19:24"); } catch (ParseException e) {
Program output:
Formatted date Sun Oct 07 00:19:24 IST 2012
Expected Result:
Formatted date Sun Oct 07 12 : 19: 24 IST 2012
source share