Oct 22, 2018

How to reset/clear time part of Calendar instance in Java

Calendar cal = Calendar.getInstance();    
cal.set(Calendar.HOUR_OF_DAY, cal.getActualMinimum(Calendar.HOUR_OF_DAY));    
cal.set(Calendar.MINUTE, cal.getActualMinimum(Calendar.MINUTE));    
cal.set(Calendar.SECOND, cal.getActualMinimum(Calendar.SECOND));    
cal.set(Calendar.MILLISECOND, cal.getActualMinimum(Calendar.MILLISECOND));
If HH refers to a 12-hour time. The 12 in the time you're retrieving is 12 midnight.If what you want is HH24, which ges you a 24-hour time, starting at 00 for midnight.