
Relying on the Default TimeZone
Calendar calendar = new GregorianCalendar();calendar.setTime(date);calendar.set(Calendar.HOUR_OF_DAY, 0);calendar.set(Calendar.MINUTE, 0);calendar.set(Calendar.SECOND, 0);Date startOfDay = calendar.getTime(); The code above calculates the start of the day (0h00). The first mistake is the missing millisecond field of the Calendar, but a major mistake is not setting the TimeZone of the Calendar object, as a result, the Calendar