I am facing weird behavior with "yyyy-MM-dd hh:mm:ss" date parsing pattern. below is my code.
public static void main(String[] args) throws Exception {
System.out.println(parseDate("2018-08-16 11:00:00"));
System.out.println(parseDate("2018-08-16 12:00:00"));
System.out.println(parseDate("2018-08-16 13:00:00"));
}
public static Date parseDate(String date) throws Exception {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
return sdf.parse(date);
}
and I am getting following output
Thu Aug 16 11:00:00 UTC 2018
Thu Aug 16 00:00:00 UTC 2018
Thu Aug 16 13:00:00 UTC 2018
I don't understand the second output why for "2018-08-16 12:00:00" its saying Thu Aug 16 00:00:00 UTC 2018 instead of Thu Aug 16 12:00:00 UTC 2018.
looking at the docs for date parsing pattern from here. It says
h -> Hour in am/pm (1-12)
can someone please explain this? Thanks in anticipation.