I need to calculate a java.util.Date for a beginning of a today day (00:00:00 a.m. of a today day). Does someone know something better than resetting fields of java.util.Calendar:
Calendar cal = Calendar.getInstance();
cal.set(Calendar.AM_PM, Calendar.AM);
cal.set(Calendar.HOUR, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
If you don’t bother about time zones then your solution is ok. Otherwise it’s worth to look at JodaTime.
If you eventually decide to switch to JodaTime, then you can use DateMidnight class which is supposed to be used in your situation.