Java Utililty Methods Day End

List of utility methods to do Day End

Description

The list of methods to do Day End are organized into topic(s).

Method

intgetEndMonth(Date sessionEnd, int year, int excessDays)
get End Month
Calendar cal = Calendar.getInstance(Locale.US);
cal.setTime(sessionEnd);
cal.add(Calendar.DAY_OF_MONTH, +excessDays);
int m = cal.get(Calendar.MONTH);
if (cal.get(Calendar.YEAR) != year)
    m += (12 * (cal.get(Calendar.YEAR) - year));
return m;
DategetEndOfDay(Date d)
Returns the last second of the day
return getDateTime(d, 23, 59, 59, 999);
DategetEndOfDay(Date date)
Set the time component as the last seconds of the day.
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.set(Calendar.HOUR_OF_DAY, cal.getActualMaximum(Calendar.HOUR_OF_DAY));
cal.set(Calendar.MINUTE, cal.getActualMaximum(Calendar.MINUTE));
cal.set(Calendar.SECOND, cal.getActualMaximum(Calendar.SECOND));
cal.set(Calendar.MILLISECOND, cal.getActualMaximum(Calendar.MILLISECOND));
return cal.getTime();
DategetEndOfDay(Date date)
get End Of Day
if (date == null)
    return null;
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.set(Calendar.HOUR_OF_DAY, 23);
cal.set(Calendar.MINUTE, 59);
cal.set(Calendar.SECOND, 59);
cal.set(Calendar.MILLISECOND, 999);
...
DategetEndOfDay(Date date)
Metodo que recebe uma data e retorna essa data com as horas modificadas para '23:59:59'
if (date == null) {
    return null;
Calendar dt = new GregorianCalendar();
dt.setTime(date);
dt.set(Calendar.HOUR_OF_DAY, 23);
dt.set(Calendar.MINUTE, 59);
dt.set(Calendar.SECOND, 59);
...
DategetEndOfDay(Date date)
Set the time component as the last seconds of the day.
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.set(Calendar.HOUR_OF_DAY, cal.getActualMaximum(Calendar.HOUR_OF_DAY));
cal.set(Calendar.MINUTE, cal.getActualMaximum(Calendar.MINUTE));
cal.set(Calendar.SECOND, cal.getActualMaximum(Calendar.SECOND));
cal.set(Calendar.MILLISECOND, cal.getActualMaximum(Calendar.MILLISECOND));
return cal.getTime();
DategetEndOfDay(Date day)
Returns the last second of the day passed as argument
Calendar cal = Calendar.getInstance();
cal.setTime(day);
cal.set(Calendar.HOUR_OF_DAY, cal.getMaximum(Calendar.HOUR_OF_DAY));
cal.set(Calendar.MINUTE, cal.getMaximum(Calendar.MINUTE));
cal.set(Calendar.SECOND, cal.getMaximum(Calendar.SECOND));
return cal.getTime();
DategetEndOfDay(Date day)
get End Of Day
final GregorianCalendar calendar = createUtcCalendar(day);
calendar.add(Calendar.DAY_OF_MONTH, 1);
calendar.set(Calendar.MILLISECOND, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.HOUR_OF_DAY, 0);
return calendar.getTime();
DategetEndOfDay(Date when)
get End Of Day
Calendar cal = Calendar.getInstance();
cal.setTime(getStartOfDay(when));
cal.add(Calendar.DATE, 1);
cal.add(Calendar.SECOND, -1);
return cal.getTime();
DategetEndOfDay(final Date date, final TimeZone timeZone)
get End Of Day
final Calendar cal = Calendar.getInstance(timeZone);
cal.setTime(date);
cal.set(Calendar.HOUR_OF_DAY, 23);
cal.set(Calendar.MINUTE, 59);
cal.set(Calendar.SECOND, 59);
cal.set(Calendar.MILLISECOND, 999);
return cal.getTime();