Java Utililty Methods Date Clear

List of utility methods to do Date Clear

Description

The list of methods to do Date Clear are organized into topic(s).

Method

DateclearDate(Date date)
clear Date
Calendar c = Calendar.getInstance();
c.setTime(date);
c.set(Calendar.YEAR, 0);
c.set(Calendar.MONTH, 0);
c.set(Calendar.DATE, 0);
return c.getTime();
DateclearDate(Date dateTime)
clear Date
if (dateTime == null) {
    return null;
Calendar cal = Calendar.getInstance();
cal.setTime(dateTime);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
...
DateclearDate(final Date date)
Set hour, minute, second and millisecond to 0.
if (date == null) {
    return null;
final Calendar calendar = GregorianCalendar.getInstance();
calendar.setTime(date);
calendar.set(Calendar.MILLISECOND, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MINUTE, 0);
...
voidclearDisplayFileCreationDateCache(final String absolutePath)
Clears cache for "getDisplayFileCreationDate" method for specified file path.
displayFileCreationDateCache.remove(absolutePath);
DateclearHourMinute(Date date)
clear Hour Minute
if (date == null)
    return null;
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.set(Calendar.HOUR, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.MILLISECOND, 0);
return calendar.getTime();
...
DateclearTime(Date date)
clear Time
Calendar calendar = getCalendarFromDate(date);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
return calendar.getTime();
DateclearTime(Date date)
clear Time
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.clear(Calendar.HOUR_OF_DAY);
cal.clear(Calendar.MINUTE);
cal.clear(Calendar.SECOND);
cal.clear(Calendar.MILLISECOND);
return cal.getTime();
voidclearTime(GregorianCalendar date)
Clears the time in a Gregorian calendar date.
date.set(Calendar.HOUR_OF_DAY, 0);
date.set(Calendar.MINUTE, 0);
date.set(Calendar.SECOND, 0);
date.set(Calendar.MILLISECOND, 0);
DateclearTimeComponent(Date date)
Given a Date object, returns a Date object for the same date but with the time component (hours, minutes, seconds & milliseconds) removed
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
return cal.getTime();