Class CalendricalMatchers
CalendricalMatcher
.
These matchers are useful and common implementations of CalendricalMatcher
.
A matcher allows any type of matching to be performed against a calendrical.
Examples might be checking of the calendrical represents Friday the Thirteenth,
or the last day of the month, or one of the American continent time-zones.
CalendricalMatchers is a utility class. All matchers returned are immutable and thread-safe.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
Class implementing day-of-week in month matcher.private static enum
Enum implementing the adjusters. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
Private constructor since this is a utility class. -
Method Summary
Modifier and TypeMethodDescriptionstatic CalendricalMatcher
dayOfWeekInMonth
(int ordinal, DayOfWeek dayOfWeek) Returns the day-of-week in month matcher, which returns true if the date is the ordinal occurrence of the day-of-week in the month.static CalendricalMatcher
firstInMonth
(DayOfWeek dayOfWeek) Returns the first in month matcher, which returns true if the date is the first occurrence of day-of-week in the month.static CalendricalMatcher
Returns the last day-of-month matcher, which returns true if the date is the last valid day of the month.static CalendricalMatcher
Returns the last day-of-year matcher, which returns true if the date is the last valid day of the year.static CalendricalMatcher
leapDay()
Returns the leap day matcher, which returns true if the date is February 29th in a leap year.static CalendricalMatcher
leapYear()
Returns the leap year matcher, which returns true if the date is in a leap year.static CalendricalMatcher
Returns the non weekend day matcher, which returns true if the date is between Monday and Friday inclusive.static CalendricalMatcher
Returns the weekend day matcher, which returns true if the date is Saturday or Sunday.
-
Constructor Details
-
CalendricalMatchers
private CalendricalMatchers()Private constructor since this is a utility class.
-
-
Method Details
-
leapYear
Returns the leap year matcher, which returns true if the date is in a leap year.- Returns:
- the leap year matcher, never null
-
leapDay
Returns the leap day matcher, which returns true if the date is February 29th in a leap year.- Returns:
- the leap day matcher, never null
-
lastDayOfMonth
Returns the last day-of-month matcher, which returns true if the date is the last valid day of the month.- Returns:
- the last day-of-month matcher, never null
-
lastDayOfYear
Returns the last day-of-year matcher, which returns true if the date is the last valid day of the year.- Returns:
- the last day-of-year matcher, never null
-
weekendDay
Returns the weekend day matcher, which returns true if the date is Saturday or Sunday.Some territories have weekends that do not consist of Saturday and Sunday. No implementation is supplied to support this, however a DateMatcher can be easily written to do so.
- Returns:
- the non weekend day matcher, never null
-
nonWeekendDay
Returns the non weekend day matcher, which returns true if the date is between Monday and Friday inclusive.Some territories have weekends that do not consist of Saturday and Sunday. No implementation is supplied to support this, however a DateMatcher can be easily written to do so.
- Returns:
- the non weekend day matcher, never null
-
firstInMonth
Returns the first in month matcher, which returns true if the date is the first occurrence of day-of-week in the month.- Parameters:
dayOfWeek
- the day-of-week, not null- Returns:
- the first in month matcher, never null
-
dayOfWeekInMonth
Returns the day-of-week in month matcher, which returns true if the date is the ordinal occurrence of the day-of-week in the month.- Parameters:
ordinal
- ordinal, from 1 to 5dayOfWeek
- the day-of-week, not null- Returns:
- the day-of-week in month matcher, never null
- Throws:
IllegalArgumentException
- if the ordinal is invalid
-