In other words, I want functionality that provides Joda-Time:
today = today.withTime(0, 0, 0, 0);
but without Joda-Time, only with java.util.Da
If you want midnight (0:00am) for the current date, you can just use the default constructor and zero out the time portions:
Date today = new Date();
today.setHours(0); today.setMinutes(0); today.setSeconds(0);
edit: update with Calendar
since those methods are deprecated
Calendar today = Calendar.getInstance();
today.clear(Calendar.HOUR); today.clear(Calendar.MINUTE); today.clear(Calendar.SECOND);
Date todayDate = today.getTime();
Date today = new Date();
today.setHours(0); //same for minutes and seconds
Since the methods are deprecated, you can do this with Calendar
:
Calendar today = Calendar.getInstance();
today.set(Calendar.HOUR_OF_DAY, 0); // same for minutes and seconds
And if you need a Date
object in the end, simply call today.getTime()