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

intdays(int month, int year)
days
if (month == 2)
    return 28 + ((year % 4 == 0) ? 1 : 0) - ((year % 4 == 100) ? 1 : 0);
if (month < 8)
    return 30 + (month % 2);
return 31 - (month % 2);
intdays(int num)
days
return hours(24 * num);
intdays(int year, int month)
days
int total = 30;
switch (month) {
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
...
intdaysAfter(Date earlierDate, Date laterDate)
days After
final Calendar earlier = CALENDAR;
final Calendar later = CALENDAR2;
if (laterDate.before(earlierDate))
    return 0;
earlier.setTime(earlierDate);
later.setTime(laterDate);
int daysLater = later.get(Calendar.DAY_OF_YEAR) - earlier.get(Calendar.DAY_OF_YEAR);
for (int year = earlier.get(Calendar.YEAR); year < later.get(Calendar.YEAR); year++) {
...
FloatdaysAndHours(int hours)
Converts hours to days and hours.
int days, hrs;
String s = null;
days = Math.abs(hours) / 24;
hrs = Math.abs(hours) % 24;
if (hrs < 10)
    s = days + ".0" + hrs;
else
    s = days + "." + hrs;
...
longdaysBetweenTime(long start, long end)
days Between Time
if (start > end) {
    return -1;
long term = end - start;
return term / (1000 * 60 * 60 * 24);
intdaysInFebruary(int year)
Given integer argument year, returns number of days in February of that year.
return (((year % 4 == 0) && ((!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28);
intdaysInMonthForYear(int commonMonthIndex, int yearInteger)
Answer the number of days in the month named monthName in the year yearInteger.
int monthIndex = commonMonthIndex - 1;
return DaysInMonth[monthIndex] + ((monthIndex == 1) ? leapYearBalance(yearInteger) : 0);
intdaysOfTwo(Date date1, Date date2)
days Of Two
Calendar aCalendar = Calendar.getInstance();
aCalendar.setTime(date1);
int day1 = aCalendar.get(Calendar.DAY_OF_YEAR);
aCalendar.setTime(date2);
int day2 = aCalendar.get(Calendar.DAY_OF_YEAR);
return day2 - day1;
ListdaysSince(Date since)
days Since
List<Date> list = new ArrayList<Date>();
Date today = getMidnight(new Date());
for (Date d = getMidnight(since); d.before(today)
        || d.equals(today); d = newDateFrom(d, Calendar.DAY_OF_YEAR, 1)) {
    list.add(d);
return list;