List of utility methods to do Day From
long | dayStartTime(int day) day Start Time return ((long) day) * DAY_SECS; |
float | distanceToNowInDaysIgnoreTime(Date date) distance To Now In Days Ignore Time return dateDiffInDaysIgnoreTime(date, new Date()); |
boolean | equalsDay(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); |
Date | explDay(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();
|
Date | firstDayOfCentury(final int century) first Day Of Century return firstDayOfYear(firstYearOfCentury(century));
|
Date | get23HourOfDay(Date date) get Hour Of Day Calendar c = Calendar.getInstance();
c.setTime(date);
c.set(Calendar.HOUR, 23);
Date date23 = c.getTime();
return date23;
|
int | getAge(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); ... |
Date | getBeforeDate_(Date date, int day) get Before Dat_ Calendar cad = Calendar.getInstance();
cad.setTime(date);
cad.add(Calendar.DATE, -day);
return cad.getTime();
|
List | getDateByDay(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; ... |
Date | getDateByNum(int day) get Date By Num GregorianCalendar gd = new GregorianCalendar(1900, 1, 1); Date date = gd.getTime(); date = nextDay(date, day); return date; |