Thursday, November 15, 2018

Java Calendar one important note that may get easily missed

Calendar.HOUR value range is from 0 - 11. This means that
calendar.set(Calendar.HOUR,12) will switch the date to next day 0. If we want to get 12pm current day

calendar.set(Calendar.HOUR,0);
calendar.set(Calendar.AM_PM,Calendar.PM) 

No comments:

Post a Comment