Java Utililty Methods Day From

List of utility methods to do Day From

Description

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

Method

longdayStartTime(int day)
day Start Time
return ((long) day) * DAY_SECS;
floatdistanceToNowInDaysIgnoreTime(Date date)
distance To Now In Days Ignore Time
return dateDiffInDaysIgnoreTime(date, new Date());
booleanequalsDay(final Date date1, final Date date2)
equals Day
final Calendar c1 = Calendar.getInstance();
c1.setTime(date1);
final Calendar c2 = Calendar.getInstance();
c2.setTime(date2);
return c1.get(Calendar.YEAR) == c2.get(Calendar.YEAR) && c1.get(Calendar.MONTH) == c2.get(Calendar.MONTH)
        && c1.get(Calendar.DAY_OF_MONTH) == c2.get(Calendar.DAY_OF_MONTH);
DateexplDay(Date date)
expl Day
explCalendar.setTime(date);
explCalendar.set(Calendar.HOUR_OF_DAY, 0);
explCalendar.set(Calendar.MINUTE, 0);
explCalendar.set(Calendar.SECOND, 0);
explCalendar.set(Calendar.MILLISECOND, 0);
return explCalendar.getTime();
DatefirstDayOfCentury(final int century)
first Day Of Century
return firstDayOfYear(firstYearOfCentury(century));
Dateget23HourOfDay(Date date)
get Hour Of Day
Calendar c = Calendar.getInstance();
c.setTime(date);
c.set(Calendar.HOUR, 23);
Date date23 = c.getTime();
return date23;
intgetAge(Date birthDay)
get Age
Calendar cal = Calendar.getInstance();
if (cal.before(birthDay)) {
    throw new IllegalArgumentException("The birthDay is before Now.It's unbelievable!");
int yearNow = cal.get(Calendar.YEAR);
int monthNow = cal.get(Calendar.MONTH);
int dayOfMonthNow = cal.get(Calendar.DAY_OF_MONTH);
cal.setTime(birthDay);
...
DategetBeforeDate_(Date date, int day)
get Before Dat_
Calendar cad = Calendar.getInstance();
cad.setTime(date);
cad.add(Calendar.DATE, -day);
return cad.getTime();
ListgetDateByDay(Date date)
get Date By Day
List<Date> dates = new ArrayList<>();
Calendar c = GregorianCalendar.getInstance();
c.setTime(date);
setTimeToBeginningOfDay(c);
dates.add(c.getTime());
setTimeToEndofDay(c);
dates.add(c.getTime());
return dates;
...
DategetDateByNum(int day)
get Date By Num
GregorianCalendar gd = new GregorianCalendar(1900, 1, 1);
Date date = gd.getTime();
date = nextDay(date, day);
return date;