Java Utililty Methods Calendar Truncate

List of utility methods to do Calendar Truncate

Description

The list of methods to do Calendar Truncate are organized into topic(s).

Method

voidtrim(final Calendar cal)
This method will trim calendar to day by setting hour,min and sec to zero.
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
voidtrimCalendar(Calendar cal)
trim Calendar
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
voidtrunc(Calendar calendar)
Truncates a date object by setting to midnight of the current date.
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
voidtruncate(Calendar calendar)
Truncate the Calendar removing hours, minutes, seconds and milliseconds
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
CalendartruncateCal(final Calendar cal)
truncate Cal
cal.set(Calendar.MILLISECOND, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.HOUR, 0);
return cal;
voidtruncCalendar(Calendar c)
truncate the calendar to a day with time 00:00:00.000
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
c.set(Calendar.MILLISECOND, 0);
voidtruncCalendarToQuarter(Calendar c)
truncate the calendar to half year (i.e.
if (c == null) {
    return;
final int month = c.get(Calendar.MONTH);
truncCalendarToYear(c);
int quarterMonth = Calendar.JANUARY;
switch (month) {
case Calendar.APRIL:
...