Parsing MM/dd/yyyy HH:mm:ss
e.g. 06-26-2017 03:54:26
into yyyy/MM/dd HH:mm:ss
does not throw parsing exception. Instead parses the date in incorrect date. How can we handle this in Java?
Below is the code snippet :
try {
Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
.parse("06-26-2017 03:54:26");
} catch (ParseException e) {
System.out.println(e);
}