com.jaxfront.core.util
Class DateCalculator

java.lang.Object
  extended by com.jaxfront.core.util.DateCalculator

public class DateCalculator
extends java.lang.Object


Field Summary
static java.text.SimpleDateFormat DEFAULT_FORMAT
           
 
Constructor Summary
DateCalculator()
           
 
Method Summary
static java.util.Date getEarliestNonExcludedDate(int daysAway, java.util.Date baseDate, int[] excludedDaysOfWeek)
          Use to find out what date is a certain number of days after a base date, not counting certain days.
static java.util.Date getEarliestNonExcludedDate(int daysAway, java.util.Date baseDate, int[] excludedDaysOfWeek, java.util.Date[] excludedDateList)
          Use to find out what date is a certain number of days after a base date, not counting certain days.
static java.util.Date getEarliestNonExcludedDate(int daysAway, java.util.Date baseDate, int[] excludedDaysOfWeek, java.util.Hashtable excludedDates)
          Use to find out what date is a certain number of days after a base date, not counting certain days.
static java.util.Date getEarliestNonExcludedDate(int daysAway, java.util.Date baseDate, int[] excludedDaysOfWeek, java.lang.String[] excludedDateList)
          Use to find out what date is a certain number of days after a base date, not counting certain days.
static boolean isExcludedDate(java.util.Calendar checkCal, java.util.Hashtable excludedDays, java.util.Hashtable excludedDates)
          Tells you if the checkCal day/date is in one of the exclusion lists
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_FORMAT

public static final java.text.SimpleDateFormat DEFAULT_FORMAT
Constructor Detail

DateCalculator

public DateCalculator()
Method Detail

getEarliestNonExcludedDate

public static java.util.Date getEarliestNonExcludedDate(int daysAway,
                                                        java.util.Date baseDate,
                                                        int[] excludedDaysOfWeek)
Use to find out what date is a certain number of days after a base date, not counting certain days.

Parameters:
daysAway - Number of non-excluded days from the baseDate that the result date will be
baseDate - Date to start counting daysAway from. If specify "null" defaults to today
excludedDaysOfWeek - Array of constants from java.util.Calendar object e.g. Calendar.SUNDAY, which are excluded from counting towards daysAway for the result
Returns:
The earliest date which is daysAway days after the baseDate. In counting towards this result date, any excludedDaysOfWeek are excluded from counting towards the daysAway
See Also:
DateBean#getEarliestNonExcludedDate(int, java.util.Date, int[], Hashtable)

getEarliestNonExcludedDate

public static java.util.Date getEarliestNonExcludedDate(int daysAway,
                                                        java.util.Date baseDate,
                                                        int[] excludedDaysOfWeek,
                                                        java.lang.String[] excludedDateList)
Use to find out what date is a certain number of days after a base date, not counting certain days.

Parameters:
daysAway - Number of non-excluded days from the baseDate that the result date will be
baseDate - Date to start counting daysAway from. If specify "null" defaults to today
excludedDaysOfWeek - Array of constants from java.util.Calendar object e.g. Calendar.SUNDAY, which are excluded from counting towards daysAway for the result
excludedDateList - Array of date strings (formatted as SimpleDateFormat.getDateInstance().format()) which represent specific dates which should be excluded from the counting of days, such as holidays
Returns:
The earliest date which is daysAway days after the baseDate. In counting towards this result date, any excludedDaysOfWeek are excluded from counting towards the daysAway
See Also:
DateBean#getEarliestNonExcludedDate(int, java.util.Date, int[], Hashtable)

getEarliestNonExcludedDate

public static java.util.Date getEarliestNonExcludedDate(int daysAway,
                                                        java.util.Date baseDate,
                                                        int[] excludedDaysOfWeek,
                                                        java.util.Date[] excludedDateList)
Use to find out what date is a certain number of days after a base date, not counting certain days.

Parameters:
daysAway - Number of non-excluded days from the baseDate that the result date will be
baseDate - Date to start counting daysAway from. If specify "null" defaults to today
excludedDaysOfWeek - Array of constants from java.util.Calendar object e.g. Calendar.SUNDAY, which are excluded from counting towards daysAway for the result
excludedDateList - Array of date objects which represent specific dates which should be excluded from the counting of days, such as holidays
Returns:
The earliest date which is daysAway days after the baseDate. In counting towards this result date, any excludedDaysOfWeek are excluded from counting towards the daysAway
See Also:
DateBean#getEarliestNonExcludedDate(int, java.util.Date, int[], Hashtable)

getEarliestNonExcludedDate

public static java.util.Date getEarliestNonExcludedDate(int daysAway,
                                                        java.util.Date baseDate,
                                                        int[] excludedDaysOfWeek,
                                                        java.util.Hashtable excludedDates)

Use to find out what date is a certain number of days after a base date, not counting certain days.

Primary example: Give me the date which is at least 3 business days from today.

Usage for example:

Parameters:
daysAway - Number of non-excluded days from the baseDate that the result date will be
baseDate - Date to start counting daysAway from. If specify "null," defaults to today
excludedDaysOfWeek - Array of constants from java.util.Calendar object e.g. Calendar.SUNDAY, which are excluded from counting towards daysAway for the result
excludedDates - Hashtable of java.util.Date objects, which represent specific dates (12:00am midnight) which should be excluded from counting towards the daysAway
Returns:
The earliest date which is daysAway days after the baseDate. In counting towards this result date, any excludedDaysOfWeek or specifically excludedDates are excluded from counting towards the daysAway

isExcludedDate

public static boolean isExcludedDate(java.util.Calendar checkCal,
                                     java.util.Hashtable excludedDays,
                                     java.util.Hashtable excludedDates)
Tells you if the checkCal day/date is in one of the exclusion lists

Parameters:
checkCal - Calendar objects representing the date to check
excludedDays - Hashtable with Integer keys representing days of the week which count as excluded. Integer keys are constants from Calendar class, e.g. Calendar.SUNDAY
excludedDates - Hashtable with elements with java.util.Date objects as keys which represent specific dates which should be excluded. Dates should all be set on 12am midnight for correct comparison.
Returns:
True if the checkCal date is one of the days or dates that are to be excluded, as specified by the excludedDays and excludedDates parameters