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

DateendOfDay(Date date)
Get the last hour, minute, second of the date specified
Calendar calendar = CALENDAR;
synchronized (calendar) {
    calendar.setTime(date);
    calendar.set(Calendar.HOUR_OF_DAY, 23);
    calendar.set(Calendar.MILLISECOND, 999);
    calendar.set(Calendar.SECOND, 59);
    calendar.set(Calendar.MINUTE, 59);
    return calendar.getTime();
...
DateendOfDay(Date date)
Sets the time field of given date to 24:00:00:00.
GregorianCalendar endOfDay = new GregorianCalendar();
endOfDay.setTime(date);
endOfDay.set(Calendar.HOUR_OF_DAY, 24);
endOfDay.set(Calendar.SECOND, 0);
endOfDay.set(Calendar.MINUTE, 0);
endOfDay.set(Calendar.MILLISECOND, 0);
return endOfDay.getTime();
DateendOfDay(Date date)
Setzt die Uhrzeit eines Datums auf 23:59:59.999.
if (date == null)
    return null;
Calendar cal = Calendar.getInstance();
cal.setTime(date == null ? new Date() : date);
cal.set(Calendar.HOUR_OF_DAY, 23);
cal.set(Calendar.MINUTE, 59);
cal.set(Calendar.SECOND, 59);
cal.set(Calendar.MILLISECOND, 999);
...
DateendOfDay(Date date)
Returns the last millisecond of the specified date.
Calendar calendar = CALENDAR;
synchronized (calendar) {
    calendar.setTime(date);
    calendar.set(Calendar.HOUR_OF_DAY, 23);
    calendar.set(Calendar.MILLISECOND, 999);
    calendar.set(Calendar.SECOND, 59);
    calendar.set(Calendar.MINUTE, 59);
    return calendar.getTime();
...
DateendOfDay(Date dateInst)
Method to return an "anti-normalized" version of the input Date whose time is set to the absolute end of that same day (last millisecond of last second of last minute of last hour).
if (dateInst == null) {
    throw new IllegalArgumentException();
final Calendar cal = new GregorianCalendar();
cal.setTime(dateInst);
cal.set(Calendar.HOUR_OF_DAY, LAST_HOUR_OF_DAY);
cal.set(Calendar.MINUTE, LAST_MINUTE);
cal.set(Calendar.SECOND, LAST_SECOND);
...
DateendOfDay(Date dt)
Returns a new date at the end of the day of the original date.
Calendar cal = Calendar.getInstance();
cal.setTime(dt);
clearTime(cal);
cal.add(Calendar.DAY_OF_MONTH, 1);
cal.add(Calendar.MILLISECOND, -1);
return cal.getTime();
DateendOfDay(Date inDate, TimeZone timeZone)
Calculate the date time at the end of the day (one millisecond before midnight) for the given date.
Calendar inCalendar = new GregorianCalendar();
inCalendar.setTimeZone(timeZone);
inCalendar.setTime(inDate);
Calendar nextDay = new GregorianCalendar(inCalendar.get(Calendar.YEAR), inCalendar.get(Calendar.MONTH),
        inCalendar.get(Calendar.DAY_OF_MONTH) + 1);
nextDay.setTimeZone(timeZone);
return new Date(nextDay.getTime().getTime());
DateendOfDay(Date value)
Return the end of a day containing a specified time
Calendar working = new GregorianCalendar();
working.setTime(value);
working.set(Calendar.HOUR_OF_DAY, 23);
working.set(Calendar.MINUTE, 59);
working.set(Calendar.SECOND, 59);
working.set(Calendar.MILLISECOND, 999);
return working.getTime();
DateendOfDay(final Date date)
end Of Day
if (date == null) {
    return null;
final Calendar dateCal = Calendar.getInstance();
dateCal.setLenient(false);
dateCal.setTime(date);
dateCal.set(Calendar.HOUR_OF_DAY, 23);
dateCal.set(Calendar.MINUTE, 59);
...
CalendarendOfDay(final Date date)
end Of Day
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
setEndOfDay(calendar);
return calendar;