Class CalendricalMatchers
- java.lang.Object
-
- javax.time.calendar.CalendricalMatchers
-
public final class CalendricalMatchers extends java.lang.Object
Provides common implementations ofCalendricalMatcher
.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 Classes Modifier and Type Class Description private static class
CalendricalMatchers.DayOfWeekInMonth
Class implementing day-of-week in month matcher.private static class
CalendricalMatchers.Impl
Enum implementing the adjusters.
-
Constructor Summary
Constructors Modifier Constructor Description private
CalendricalMatchers()
Private constructor since this is a utility class.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static 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
lastDayOfMonth()
Returns the last day-of-month matcher, which returns true if the date is the last valid day of the month.static CalendricalMatcher
lastDayOfYear()
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
nonWeekendDay()
Returns the non weekend day matcher, which returns true if the date is between Monday and Friday inclusive.static CalendricalMatcher
weekendDay()
Returns the weekend day matcher, which returns true if the date is Saturday or Sunday.
-
-
-
Method Detail
-
leapYear
public static CalendricalMatcher 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
public static CalendricalMatcher 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
public static CalendricalMatcher 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
public static CalendricalMatcher 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
public static CalendricalMatcher 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
public static CalendricalMatcher 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
public 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.- Parameters:
dayOfWeek
- the day-of-week, not null- Returns:
- the first in month matcher, never null
-
dayOfWeekInMonth
public static 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.- Parameters:
ordinal
- ordinal, from 1 to 5dayOfWeek
- the day-of-week, not null- Returns:
- the day-of-week in month matcher, never null
- Throws:
java.lang.IllegalArgumentException
- if the ordinal is invalid
-
-