public abstract class InstantMatchers extends Object
Matcher instances for comparing ZonedDateTime instances| Constructor and Description |
|---|
InstantMatchers() |
| Modifier and Type | Method and Description |
|---|---|
static TemporalMatcher<Instant> |
after(Instant date)
Creates a matcher that matches when the examined date is after the reference date
For example:
|
static TemporalMatcher<Instant> |
after(int year,
Month month,
int dayOfMonth,
int hour,
int minute,
int second,
int nanos,
ZoneId tz)
Creates a matcher that matches when the examined date is after the end of the reference year
For example:
|
static TemporalMatcher<Instant> |
before(Instant date)
Creates a matcher that matches when the examined date is before the reference date
For example:
|
static TemporalMatcher<Instant> |
before(int year,
Month month,
int dayOfMonth,
int hour,
int minute,
int second,
int nanos,
ZoneId tz)
Creates a matcher that matches when the examined date is before the end of the reference year
For example:
|
static TemporalMatcher<Instant> |
isApril()
Creates a matcher that matches when the examined date is in April
For example:
|
static TemporalMatcher<Instant> |
isAugust()
Creates a matcher that matches when the examined date is in August
For example:
|
static TemporalMatcher<Instant> |
isDay(int year,
Month month,
int dayOfMonth)
Creates a matcher that matches when the examined date is on the same day of the year as the reference date
For example:
|
static TemporalMatcher<Instant> |
isDay(int year,
Month month,
int dayOfMonth,
ZoneId zone)
Creates a matcher that matches when the examined date is on the same day of the year as the reference date
For example:
|
static TemporalMatcher<Instant> |
isDay(LocalDate date)
Creates a matcher that matches when the examined date is on the same day of the year as the reference date
For example:
|
static TemporalMatcher<Instant> |
isDayOfMonth(int dayOfMonth)
Creates a matcher that matches when the examined date is on the expected day of the month
For example:
|
static TemporalMatcher<Instant> |
isDayOfWeek(DayOfWeek... daysOfWeek)
Creates a matcher that matches when the examined date is on the same day of the week as any of the supplied days
For example:
|
static TemporalMatcher<Instant> |
isDayOfWeek(DayOfWeek dayOfWeek)
Creates a matcher that matches when the examined date is on the same day of the week as the supplied day
For example:
|
static TemporalMatcher<Instant> |
isDecember()
Creates a matcher that matches when the examined date is in December
For example:
|
static TemporalMatcher<Instant> |
isFebruary()
Creates a matcher that matches when the examined date is in February
For example:
|
static TemporalMatcher<Instant> |
isFirstDayOfMonth()
Creates a matcher that matches when the examined date is on the first day of the month
For example:
|
static TemporalMatcher<Instant> |
isFriday()
Creates a matcher that matches when the examined date is on a friday
For example:
|
static TemporalMatcher<Instant> |
isHour(int hour)
Creates a matcher that matches when the examined date is on the expected hour (0-23)
For example:
|
static TemporalMatcher<Instant> |
isInstant(int year,
Month month,
int dayOfMonth,
int hour,
int minute,
int second,
int nanos,
ZoneId tz)
Creates a matcher that matches when the examined date is at the same specified instance down to the second
For example:
|
static TemporalMatcher<Instant> |
isJanuary()
Creates a matcher that matches when the examined date is in January
For example:
|
static TemporalMatcher<Instant> |
isJuly()
Creates a matcher that matches when the examined date is in July
For example:
|
static TemporalMatcher<Instant> |
isJune()
Creates a matcher that matches when the examined date is in June
For example:
|
static TemporalMatcher<Instant> |
isLastDayOfMonth()
Creates a matcher that matches when the examined date is on the first day of the month
For example:
|
static TemporalMatcher<Instant> |
isLeapYear()
Creates a matcher that matches when the examined date is a leap year
For example:
|
static TemporalMatcher<Instant> |
isMarch()
Creates a matcher that matches when the examined date is in March
For example:
|
static TemporalMatcher<Instant> |
isMaximum(ChronoField field)
Creates a matcher that matches when the examined date is on the maximum value of the given date part in its
period
For example:
|
static TemporalMatcher<Instant> |
isMay()
Creates a matcher that matches when the examined date is in May
For example:
|
static TemporalMatcher<Instant> |
isMinimum(ChronoField field)
Creates a matcher that matches when the examined date is on the maximum value of the given date part in its
period
For example:
|
static TemporalMatcher<Instant> |
isMinute(int minute)
Creates a matcher that matches when the examined date is on the expected minute (0-59)
For example:
|
static TemporalMatcher<Instant> |
isMonday()
Creates a matcher that matches when the examined date is on a monday
For example:
|
static TemporalMatcher<Instant> |
isMonth(Month month)
Creates a matcher that matches when the examined date is in the expected month
For example:
|
static TemporalMatcher<Instant> |
isNovember()
Creates a matcher that matches when the examined date is in November
For example:
|
static TemporalMatcher<Instant> |
isOctober()
Creates a matcher that matches when the examined date is in October
For example:
|
static TemporalMatcher<Instant> |
isSaturday()
Creates a matcher that matches when the examined date is on a saturday
For example:
|
static TemporalMatcher<Instant> |
isSecond(int second)
Creates a matcher that matches when the examined date is on the expected second (0-59)
For example:
|
static TemporalMatcher<Instant> |
isSeptember()
Creates a matcher that matches when the examined date is in September
For example:
|
static TemporalMatcher<Instant> |
isSunday()
Creates a matcher that matches when the examined date is on a sunday
For example:
|
static TemporalMatcher<Instant> |
isThursday()
Creates a matcher that matches when the examined date is on a thursday
For example:
|
static TemporalMatcher<Instant> |
isToday()
Creates a matcher that matches when the examined date is today
For example:
|
static TemporalMatcher<Instant> |
isTomorrow()
Creates a matcher that matches when the examined date is tomorrow
For example:
|
static TemporalMatcher<Instant> |
isTuesday()
Creates a matcher that matches when the examined date is on a tuesday
For example:
|
static TemporalMatcher<Instant> |
isWednesday()
Creates a matcher that matches when the examined date is on a wednesday
For example:
|
static TemporalMatcher<Instant> |
isWeekday()
Creates a matcher that matches when the examined date is on a weekday
For example:
|
static TemporalMatcher<Instant> |
isWeekend()
Creates a matcher that matches when the examined date is on a weekend
For example:
|
static TemporalMatcher<Instant> |
isYear(int year)
Creates a matcher that matches when the examined date is on the same year as the reference year
For example:
|
static TemporalMatcher<Instant> |
isYesterday()
Creates a matcher that matches when the examined date is yesterday
For example:
|
static TemporalMatcher<Instant> |
sameDay(Instant date)
Creates a matcher that matches when the examined date is on the same day of the year as the reference date
For example:
|
static TemporalMatcher<Instant> |
sameDayOfMonth(Instant date)
Creates a matcher that matches when the examined date is on the same day of the month as the reference date
For example:
|
static TemporalMatcher<Instant> |
sameDayOfWeek(Instant date)
Creates a matcher that matches when the examined date is on the same day of the week as the reference date
For example:
|
static TemporalMatcher<Instant> |
sameHourOfDay(Instant date)
Creates a matcher that matches when the examined date is on the same hour as the reference date
For example:
|
static TemporalMatcher<Instant> |
sameInstant(Instant date)
Creates a matcher that matches when the examined date is at the same instant as the reference date
For example:
|
static TemporalMatcher<Instant> |
sameMinuteOfHour(Instant date)
Creates a matcher that matches when the examined date is on the same minute as the reference date
For example:
|
static TemporalMatcher<Instant> |
sameMonthOfYear(Instant date)
Creates a matcher that matches when the examined date is on the same month as the reference date
For example:
|
static TemporalMatcher<Instant> |
sameOrAfter(Instant date)
Creates a matcher that matches when the examined date is at the same instant or after the reference date
For example:
|
static TemporalMatcher<Instant> |
sameOrAfter(int year,
Month month,
int day,
int hour,
int minute,
int second,
int nanos,
ZoneId tz)
Creates a matcher that matches when the examined date is on the same day or before the start of the reference
date
For example:
|
static TemporalMatcher<Instant> |
sameOrBefore(Instant date)
Creates a matcher that matches when the examined date is at the same instant or before the reference date
For example:
|
static TemporalMatcher<Instant> |
sameOrBefore(int year,
Month month,
int day,
int hour,
int minute,
int second,
int nanos,
ZoneId tz)
Creates a matcher that matches when the examined date is on the same day or before the start of the reference
date
For example:
|
static TemporalMatcher<Instant> |
sameSecondOfMinute(Instant date)
Creates a matcher that matches when the examined date is on the same second as the reference date
For example:
|
static TemporalMatcher<Instant> |
sameYear(Instant date)
Creates a matcher that matches when the examined date is on the same year as the reference date
For example:
|
static TemporalMatcher<Instant> |
within(long period,
ChronoUnit unit,
Instant date)
Creates a matcher that matches when the examined date is within a defined period the reference date
For example:
|
static TemporalMatcher<Instant> |
within(long period,
ChronoUnit unit,
int year,
Month month,
int dayofMonth,
int hour,
int minute,
int second,
int nanos,
ZoneId tz)
Creates a matcher that matches when the examined date is within a given period of the reference date
For example:
|
public static TemporalMatcher<Instant> after(Instant date)
MatcherAssert.assertThat(myDate, after(Instant.now()));
date - the reference date against which the examined date is checkedpublic static TemporalMatcher<Instant> after(int year, Month month, int dayOfMonth, int hour, int minute, int second, int nanos, ZoneId tz)
MatcherAssert.assertThat(myDate, after(2012, Month.MAY, 12));
year - the year against which the examined date is checkedmonth - the month against which the examined date is checkeddayOfMonth - the day of the month against which the examined date is checkedhour - the hour of the dayminute - the minute of the hoursecond - the second of the minutenanos - the nanos of the secondpublic static TemporalMatcher<Instant> before(Instant date)
MatcherAssert.assertThat(myDate, before(Instant.now()));
date - the reference date against which the examined date is checkedpublic static TemporalMatcher<Instant> before(int year, Month month, int dayOfMonth, int hour, int minute, int second, int nanos, ZoneId tz)
MatcherAssert.assertThat(myDate, before(2012, Month.MAY, 12));
year - the year against which the examined date is checkedmonth - the month against which the examined date is checkeddayOfMonth - the day of the month against which the examined date is checkedhour - the hour of the dayminute - the minute of the hoursecond - the second of the minutenanos - the nanos of the secondpublic static TemporalMatcher<Instant> sameDay(Instant date)
assertThat(myDate, sameDay(Instant.now()));
date - the reference date against which the examined date is checkedpublic static TemporalMatcher<Instant> isDay(LocalDate date)
assertThat(myDate, sameDay(LocalDate.now()))
date - the reference date against which the examined date is checkedpublic static TemporalMatcher<Instant> isDay(int year, Month month, int dayOfMonth)
assertThat(myDate, sameDay(2012, Month.JAN, 1))
dayOfMonth - the reference day of the month against which the examined date is checkedmonth - the reference month against which the examined date is checkedyear - the reference year against which the examined date is checkedpublic static TemporalMatcher<Instant> isDay(int year, Month month, int dayOfMonth, ZoneId zone)
assertThat(myDate, sameDay(2012, Month.JAN, 1))
dayOfMonth - the reference day of the month against which the examined date is checkedmonth - the reference month against which the examined date is checkedyear - the reference year against which the examined date is checkedpublic static TemporalMatcher<Instant> sameInstant(Instant date)
assertThat(myDate, sameInstant(Instant.now()));
date - the reference date against which the examined date is checkedpublic static TemporalMatcher<Instant> isInstant(int year, Month month, int dayOfMonth, int hour, int minute, int second, int nanos, ZoneId tz)
assertThat(myDate, sameInstant(2012, Month.JAN, 1, 3, 15, 0))
dayOfMonth - the reference day of the month against which the examined date is checkedmonth - the reference month against which the examined date is checkedyear - the reference year against which the examined date is checkedhour - the hour of the dayminute - the minute of the hoursecond - the second of the minutenanos - the nanosecond of the secondtz - the timezonepublic static TemporalMatcher<Instant> sameOrBefore(Instant date)
assertThat(myDate, sameOrBefore(Instant.now()))
date - the reference date against which the examined date is checkedpublic static TemporalMatcher<Instant> sameOrBefore(int year, Month month, int day, int hour, int minute, int second, int nanos, ZoneId tz)
assertThat(myDate, sameOrBefore(2012, Months.MAY, 12, 11, 59, 59, ZoneId.systemDefault()));
year - the year against which the examined date is checkedmonth - the month against which the examined date is checkedday - the day of the month against which the examined date is checkedhour - the hour of the dayminute - the minute of the hoursecond - the second of the minutenanos - the nanosecond of the secondtz - the time zone of the date to check againstpublic static TemporalMatcher<Instant> sameOrAfter(Instant date)
assertThat(myDate, sameOrAfter(Instant.now()))
date - the reference date against which the examined date is checkedpublic static TemporalMatcher<Instant> sameOrAfter(int year, Month month, int day, int hour, int minute, int second, int nanos, ZoneId tz)
assertThat(myDate, sameOrAfter(2012, Months.MAY, 12, 11, 59, 59, ZoneId.systemDefault()));
year - the year against which the examined date is checkedmonth - the month against which the examined date is checkedday - the day of the month against which the examined date is checkedhour - the hour of the dayminute - the minute of the hoursecond - the second of the minutenanos - the nanosecond of the secondtz - the time zone of the date to check againstpublic static TemporalMatcher<Instant> sameMonthOfYear(Instant date)
assertThat(myDate, sameMonth(Instant.now()))
date - the reference date against which the examined date is checkedpublic static TemporalMatcher<Instant> sameDayOfMonth(Instant date)
assertThat(myDate, sameDayOfMonth(Instant.now()))
date - the reference date against which the examined date is checkedpublic static TemporalMatcher<Instant> isDayOfMonth(int dayOfMonth)
assertThat(myDate, isDayOfMonth(4))
dayOfMonth - the expected day of the monthpublic static TemporalMatcher<Instant> sameYear(Instant date)
assertThat(myDate, sameYear(Instant.now()))
date - the reference date against which the examined date is checkedpublic static TemporalMatcher<Instant> isYear(int year)
assertThat(myDate, sameYear(2013))
year - the reference year against which the examined date is checkedpublic static TemporalMatcher<Instant> within(long period, ChronoUnit unit, Instant date)
assertThat(myDate, within(10, TimeUnit.DAYS, Moments.today()))
date - the reference date against which the examined date is checkedpublic static TemporalMatcher<Instant> within(long period, ChronoUnit unit, int year, Month month, int dayofMonth, int hour, int minute, int second, int nanos, ZoneId tz)
assertThat(myDate, within(5, TimeUnit.DAYS, 2012, Months.MAY, 12));
period - the timeunit interval the examined date should be withunit - the timeunit to define the length of the periodyear - the year against which the examined date is checkedmonth - the month against which the examined date is checkeddayofMonth - the day of the month against which the examined date is checkedhour - the hour of the dayminute - the minute of the hoursecond - the second of the minutenanos - the nanoseconds of the secondtz - the time zone of the reference datepublic static TemporalMatcher<Instant> isYesterday()
assertThat(myDate, isToday());
public static TemporalMatcher<Instant> isToday()
assertThat(myDate, isToday());
public static TemporalMatcher<Instant> isTomorrow()
assertThat(myDate, isTomorrow());
public static TemporalMatcher<Instant> sameDayOfWeek(Instant date)
assertThat(myDate, sameDayOfWeek(LocalDateTime.now()))
date - the reference date against which the examined date is checkedpublic static TemporalMatcher<Instant> isDayOfWeek(DayOfWeek dayOfWeek)
assertThat(myDate, isMonday());
public static TemporalMatcher<Instant> isDayOfWeek(DayOfWeek... daysOfWeek)
assertThat(myDate, isMonday());
public static TemporalMatcher<Instant> isMonday()
assertThat(myDate, isMonday());
public static TemporalMatcher<Instant> isTuesday()
assertThat(myDate, isTuesday());
public static TemporalMatcher<Instant> isWednesday()
assertThat(myDate, isWednesday());
public static TemporalMatcher<Instant> isThursday()
assertThat(myDate, isThursday());
public static TemporalMatcher<Instant> isFriday()
assertThat(myDate, isFriday());
public static TemporalMatcher<Instant> isSaturday()
assertThat(myDate, isSaturday());
public static TemporalMatcher<Instant> isSunday()
assertThat(myDate, isSunday());
public static TemporalMatcher<Instant> isWeekday()
assertThat(myDate, isWeekday());
public static TemporalMatcher<Instant> isWeekend()
assertThat(myDate, isWeekend());
public static TemporalMatcher<Instant> isFirstDayOfMonth()
assertThat(myDate, isFirstDayOfMonth());
public static TemporalMatcher<Instant> isMinimum(ChronoField field)
assertThat(myDate, isMaximumDayOfMonth(ChronoField.DAY_OF_MONTH));
field - the temporal field to checkpublic static TemporalMatcher<Instant> isLastDayOfMonth()
assertThat(myDate, isFirstDayOfMonth());
public static TemporalMatcher<Instant> isMaximum(ChronoField field)
assertThat(myDate, isMaximum(ChronoField.DAY_OF_MONTH));
field - the temporal field to checkpublic static TemporalMatcher<Instant> isMonth(Month month)
assertThat(myDate, isMonth(Month.AUGUST));
public static TemporalMatcher<Instant> isJanuary()
assertThat(myDate, isJanuary());
public static TemporalMatcher<Instant> isFebruary()
assertThat(myDate, isFebruary());
public static TemporalMatcher<Instant> isMarch()
assertThat(myDate, isMarch());
public static TemporalMatcher<Instant> isApril()
assertThat(myDate, isApril());
public static TemporalMatcher<Instant> isMay()
assertThat(myDate, isMay());
public static TemporalMatcher<Instant> isJune()
assertThat(myDate, isJune());
public static TemporalMatcher<Instant> isJuly()
assertThat(myDate, isJuly());
public static TemporalMatcher<Instant> isAugust()
assertThat(myDate, isAugust());
public static TemporalMatcher<Instant> isSeptember()
assertThat(myDate, isSeptember());
public static TemporalMatcher<Instant> isOctober()
assertThat(myDate, isOctober());
public static TemporalMatcher<Instant> isNovember()
assertThat(myDate, isNovember());
public static TemporalMatcher<Instant> isDecember()
assertThat(myDate, isDecember());
public static TemporalMatcher<Instant> isLeapYear()
assertThat(myDate, isLeapYear());
public static TemporalMatcher<Instant> isHour(int hour)
assertThat(myDate, isHour(12));
hour - the hour of the day (0-23)public static TemporalMatcher<Instant> sameHourOfDay(Instant date)
assertThat(myDate, sameHourOfDay(Instant.now()))
date - the reference date against which the examined date is checkedpublic static TemporalMatcher<Instant> isMinute(int minute)
assertThat(myDate, isMinute(12));
minute - the minute of the day (0-59)public static TemporalMatcher<Instant> sameMinuteOfHour(Instant date)
assertThat(myDate, sameMinuteOfHour(Instant.now()))
date - the reference date against which the examined date is checkedpublic static TemporalMatcher<Instant> isSecond(int second)
assertThat(myDate, isSecond(12));
second - the second of the day (0-59)public static TemporalMatcher<Instant> sameSecondOfMinute(Instant date)
assertThat(myDate, sameSecondOfMinute(Instant.now()))
date - the reference date against which the examined date is checkedCopyright © 2021 eXparity Limited. All rights reserved.