Set Calendar to Mid night
import java.util.Calendar;
public class Main {
public static void main(String[] argv) {
}
public Calendar toMidnight() {
Calendar cal = Calendar.getInstance();
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
return cal;
}
}
Home
Java Book
Runnable examples
Java Book
Runnable examples
Date Set:
- Set Date to Noon
- Set Date to the first millisecond of the day, just after midnight.
- Set Date to the first millisecond of the month, just after midnight.
- Set Date to the last millisecond of the day, just before midnight.
- Set Date to the last millisecond of the minute.
- Set Date to the last millisecond of the month, just before midnight.
- Set date to clear the time values
- Set date to the end of the day
- Set Date to the start of the day
- Set date to the end of a day
- Set date to the start of an hour
- Set date to then end of an hour
- Set date to the start of a minute
- Set date to the end of a minute
- Set Calendar to Mid night
- Set year, month and day to a date
- Roll java.util.Date back and forth