Java Day Of Year dateOfYearBetween(final int month, final int dayOfMonth, final int fromMonth, final int fromDayOfMonth, final int toMonth, final int toDayOfMonth)

Here you can find the source of dateOfYearBetween(final int month, final int dayOfMonth, final int fromMonth, final int fromDayOfMonth, final int toMonth, final int toDayOfMonth)

Description

date Of Year Between

License

Open Source License

Declaration

public static boolean dateOfYearBetween(final int month, final int dayOfMonth, final int fromMonth,
            final int fromDayOfMonth, final int toMonth, final int toDayOfMonth) 

Method Source Code

//package com.java2s;
// ProjectForge is dual-licensed.

public class Main {
    public static boolean dateOfYearBetween(final int month, final int dayOfMonth, final int fromMonth,
            final int fromDayOfMonth, final int toMonth, final int toDayOfMonth) {
        if (fromMonth == toMonth) {
            if (month != fromMonth) {
                return false;
            }//from   ww  w . ja v a  2  s.  co  m
            if (dayOfMonth < fromDayOfMonth || dayOfMonth > toDayOfMonth) {
                return false;
            }
        } else if (fromMonth < toMonth) {
            // e. g. APR - JUN
            if (month < fromMonth || month > toMonth) {
                // e. g. FEB or JUL
                return false;
            } else if (month == fromMonth && dayOfMonth < fromDayOfMonth) {
                return false;
            } else if (month == toMonth && dayOfMonth > toDayOfMonth) {
                return false;
            }
        } else if (fromMonth > toMonth) {
            // e. g. NOV - FEB
            if (month > toMonth && month < fromMonth) {
                // e. g. MAR
                return false;
            } else if (month == fromMonth && dayOfMonth < fromDayOfMonth) {
                return false;
            } else if (month == toMonth && dayOfMonth > toDayOfMonth) {
                return false;
            }
        }
        return true;
    }
}

Related

  1. currentYearMonthDay()
  2. dayOfYear(final int year, final int month, final int day)
  3. dayOfYear(int month, int day, int year)
  4. dayOfYear(int year, int month, int date)
  5. dayOfYear(int year, int month, int day)