public abstract class LocalDateTimeMatchers extends Object
Matcher instances for
comparing LocalDateTime instances| Constructor and Description |
|---|
LocalDateTimeMatchers() |
| Modifier and Type | Method and Description |
|---|---|
static org.hamcrest.Matcher<LocalDateTime> |
after(int year,
Month month,
int dayOfMonth,
int hour,
int minute,
int second)
Creates a matcher that matches when the examined date is after the end of
the reference year
For example:
|
static org.hamcrest.Matcher<LocalDateTime> |
after(LocalDateTime date)
Creates a matcher that matches when the examined date is after the
reference date
For example:
|
static org.hamcrest.Matcher<LocalDateTime> |
before(int year,
Month month,
int dayOfMonth,
int hour,
int minute,
int second)
Creates a matcher that matches when the examined date is before the end
of the reference year
For example:
|
static org.hamcrest.Matcher<LocalDateTime> |
before(LocalDateTime date)
Creates a matcher that matches when the examined date is before the
reference date
For example:
|
static org.hamcrest.Matcher<LocalDateTime> |
isApril()
Creates a matcher that matches when the examined date is in April
For example:
|
static org.hamcrest.Matcher<LocalDateTime> |
isAugust()
Creates a matcher that matches when the examined date is in August
For example:
|
static org.hamcrest.Matcher<LocalDateTime> |
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 org.hamcrest.Matcher<LocalDateTime> |
isDayOfMonth(int dayOfMonth)
Creates a matcher that matches when the examined date is on the expected
day of the month
For example:
|
static org.hamcrest.Matcher<LocalDateTime> |
isDayOfWeek(DayOfWeek... dayOfWeek)
Creates a matcher that matches when the examined date is on a monday
For example:
|
static org.hamcrest.Matcher<LocalDateTime> |
isDecember()
Creates a matcher that matches when the examined date is in December
For example:
|
static org.hamcrest.Matcher<LocalDateTime> |
isFebruary()
Creates a matcher that matches when the examined date is in February
For example:
|
static org.hamcrest.Matcher<LocalDateTime> |
isFirstDayOfMonth()
Creates a matcher that matches when the examined date is on the first day
of the month
For example:
|
static org.hamcrest.Matcher<LocalDateTime> |
isFriday()
Creates a matcher that matches when the examined date is on a friday
For example:
|
static org.hamcrest.Matcher<LocalDateTime> |
isHour(int hour)
Creates a matcher that matches when the examined date is on the expected
hour (0-23)
For example:
|
static org.hamcrest.Matcher<LocalDateTime> |
isInstant(int year,
Month month,
int dayOfMonth,
int hour,
int minute,
int second,
int nanos)
Creates a matcher that matches when the examined date is at the same
specified instance down to the second
For example:
|
static org.hamcrest.Matcher<LocalDateTime> |
isJanuary()
Creates a matcher that matches when the examined date is in January
For example:
|
static org.hamcrest.Matcher<LocalDateTime> |
isJuly()
Creates a matcher that matches when the examined date is in July
For example:
|
static org.hamcrest.Matcher<LocalDateTime> |
isJune()
Creates a matcher that matches when the examined date is in June
For example:
|
static org.hamcrest.Matcher<LocalDateTime> |
isLastDayOfMonth()
Creates a matcher that matches when the examined date is on the first day
of the month
For example:
|
static org.hamcrest.Matcher<LocalDateTime> |
isLeapYear()
Creates a matcher that matches when the examined date is a leap year
For example:
|
static org.hamcrest.Matcher<LocalDateTime> |
isMarch()
Creates a matcher that matches when the examined date is in March
For example:
|
static org.hamcrest.Matcher<LocalDateTime> |
isMaximum(TemporalField 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 org.hamcrest.Matcher<LocalDateTime> |
isMay()
Creates a matcher that matches when the examined date is in May
For example:
|
static org.hamcrest.Matcher<LocalDateTime> |
isMinimum(TemporalField 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 org.hamcrest.Matcher<LocalDateTime> |
isMinute(int minute)
Creates a matcher that matches when the examined date is on the expected
minute (0-59)
For example:
|
static org.hamcrest.Matcher<LocalDateTime> |
isMonday()
Creates a matcher that matches when the examined date is on a monday
For example:
|
static org.hamcrest.Matcher<LocalDateTime> |
isMonth(Month month)
Creates a matcher that matches when the examined date is in the expected
month
For example:
|
static org.hamcrest.Matcher<LocalDateTime> |
isNovember()
Creates a matcher that matches when the examined date is in November
For example:
|
static org.hamcrest.Matcher<LocalDateTime> |
isOctober()
Creates a matcher that matches when the examined date is in October
For example:
|
static org.hamcrest.Matcher<LocalDateTime> |
isSaturday()
Creates a matcher that matches when the examined date is on a saturday
For example:
|
static org.hamcrest.Matcher<LocalDateTime> |
isSecond(int Second)
Creates a matcher that matches when the examined date is on the expected
second (0-59)
For example:
|
static org.hamcrest.Matcher<LocalDateTime> |
isSeptember()
Creates a matcher that matches when the examined date is in September
For example:
|
static org.hamcrest.Matcher<LocalDateTime> |
isSunday()
Creates a matcher that matches when the examined date is on a sunday
For example:
|
static org.hamcrest.Matcher<LocalDateTime> |
isThursday()
Creates a matcher that matches when the examined date is on a thursday
For example:
|
static org.hamcrest.Matcher<LocalDateTime> |
isToday()
Creates a matcher that matches when the examined date is today
For example:
|
static org.hamcrest.Matcher<LocalDateTime> |
isTomorrow()
Creates a matcher that matches when the examined date is tomorrow
For example:
|
static org.hamcrest.Matcher<LocalDateTime> |
isTuesday()
Creates a matcher that matches when the examined date is on a tuesday
For example:
|
static org.hamcrest.Matcher<LocalDateTime> |
isWednesday()
Creates a matcher that matches when the examined date is on a wednesday
For example:
|
static org.hamcrest.Matcher<LocalDateTime> |
isWeekday()
Creates a matcher that matches when the examined date is on a weekday
For example:
|
static org.hamcrest.Matcher<LocalDateTime> |
isWeekend()
Creates a matcher that matches when the examined date is on a weekend
For example:
|
static org.hamcrest.Matcher<LocalDateTime> |
isYear(int year)
Creates a matcher that matches when the examined date is on the same year
as the reference year
For example:
|
static org.hamcrest.Matcher<LocalDateTime> |
isYesterday()
Creates a matcher that matches when the examined date is yesterday
For example:
|
static org.hamcrest.Matcher<LocalDateTime> |
sameDay(LocalDateTime 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 org.hamcrest.Matcher<LocalDateTime> |
sameDayOfMonth(LocalDateTime 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 org.hamcrest.Matcher<LocalDateTime> |
sameDayOfWeek(LocalDateTime 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 org.hamcrest.Matcher<LocalDateTime> |
sameHourOfDay(LocalDateTime date)
Creates a matcher that matches when the examined date is on the same hour
as the reference date
For example:
|
static org.hamcrest.Matcher<LocalDateTime> |
sameInstant(LocalDateTime date)
Creates a matcher that matches when the examined date is at the same
instant as the reference date
For example:
|
static org.hamcrest.Matcher<LocalDateTime> |
sameMinuteOfHour(LocalDateTime date)
Creates a matcher that matches when the examined date is on the same
minute as the reference date
For example:
|
static org.hamcrest.Matcher<LocalDateTime> |
sameMonthOfYear(LocalDateTime date)
Creates a matcher that matches when the examined date is on the same
month as the reference date
For example:
|
static org.hamcrest.Matcher<LocalDateTime> |
sameOrAfter(int year,
Month month,
int day,
int hour,
int minute,
int second)
Creates a matcher that matches when the examined date is on the same day
or after the start of the reference date
For example:
|
static org.hamcrest.Matcher<LocalDateTime> |
sameOrAfter(LocalDateTime date)
Creates a matcher that matches when the examined date is at the same
instant or after the reference date
For example:
|
static org.hamcrest.Matcher<LocalDateTime> |
sameOrBefore(int year,
Month month,
int day,
int hour,
int minute,
int second)
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 org.hamcrest.Matcher<LocalDateTime> |
sameOrBefore(LocalDateTime date)
Creates a matcher that matches when the examined date is at the same
instant or before the reference date
For example:
|
static org.hamcrest.Matcher<LocalDateTime> |
sameSecondOfMinute(LocalDateTime date)
Creates a matcher that matches when the examined date is on the same
second as the reference date
For example:
|
static org.hamcrest.Matcher<LocalDateTime> |
sameYear(LocalDateTime date)
Creates a matcher that matches when the examined date is on the same year
as the reference date
For example:
|
static org.hamcrest.Matcher<LocalDateTime> |
within(long period,
ChronoUnit unit,
int year,
Month month,
int dayofMonth,
int hour,
int minute,
int second,
int nanos)
Creates a matcher that matches when the examined date is within a given
period of the reference date
For example:
|
static org.hamcrest.Matcher<LocalDateTime> |
within(long period,
ChronoUnit unit,
LocalDateTime date)
Creates a matcher that matches when the examined date is within a defined
period the reference date
For example:
|
public static org.hamcrest.Matcher<LocalDateTime> after(LocalDateTime date)
MatcherAssert.assertThat(myDate, LocalDateTimeMatchers.after(LocalDateTime.now()));
date - the reference date against which the examined date is checkedpublic static org.hamcrest.Matcher<LocalDateTime> after(int year, Month month, int dayOfMonth, int hour, int minute, int second)
MatcherAssert.assertThat(myDate, LocalDateTimeMatchers.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 minutepublic static org.hamcrest.Matcher<LocalDateTime> before(LocalDateTime date)
MatcherAssert.assertThat(myDate, LocalDateTimeMatchers.before(LocalDateTime.now()));
date - the reference date against which the examined date is checkedpublic static org.hamcrest.Matcher<LocalDateTime> before(int year, Month month, int dayOfMonth, int hour, int minute, int second)
MatcherAssert.assertThat(myDate, LocalDateTimeMatchers.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 minutepublic static org.hamcrest.Matcher<LocalDateTime> sameDay(LocalDateTime date)
assertThat(myDate, sameDay(LocalDateTime.now()));
date - the reference date against which the examined date is checkedpublic static org.hamcrest.Matcher<LocalDateTime> 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 org.hamcrest.Matcher<LocalDateTime> sameInstant(LocalDateTime date)
assertThat(myDate, sameInstant(LocalDateTime.now()));
date - the reference date against which the examined date is checkedpublic static org.hamcrest.Matcher<LocalDateTime> isInstant(int year, Month month, int dayOfMonth, int hour, int minute, int second, int nanos)
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 secondpublic static org.hamcrest.Matcher<LocalDateTime> sameOrBefore(LocalDateTime date)
assertThat(myDate, isSameOrBefore(new Date()))
date - the reference date against which the examined date is checkedpublic static org.hamcrest.Matcher<LocalDateTime> sameOrBefore(int year, Month month, int day, int hour, int minute, int second)
assertThat(myDate, isSameOrBefore(2012, Months.MAY, 12));
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 minutepublic static org.hamcrest.Matcher<LocalDateTime> sameOrAfter(LocalDateTime date)
assertThat(myDate, isSameOrAfter(new Date()))
date - the reference date against which the examined date is checkedpublic static org.hamcrest.Matcher<LocalDateTime> sameOrAfter(int year, Month month, int day, int hour, int minute, int second)
assertThat(myDate, isSameOrAfter(2012, Months.MAY, 12));
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 minutepublic static org.hamcrest.Matcher<LocalDateTime> sameMonthOfYear(LocalDateTime date)
assertThat(myDate, sameMonth(new Date()))
date - the reference date against which the examined date is checkedpublic static org.hamcrest.Matcher<LocalDateTime> sameDayOfMonth(LocalDateTime date)
assertThat(myDate, sameDayOfMonth(new Date()))
date - the reference date against which the examined date is checkedpublic static org.hamcrest.Matcher<LocalDateTime> isDayOfMonth(int dayOfMonth)
assertThat(myDate, isDayOfMonth(4))
date - the expected day of the monthpublic static org.hamcrest.Matcher<LocalDateTime> sameYear(LocalDateTime date)
assertThat(myDate, sameYear(new Date()))
date - the reference date against which the examined date is checkedpublic static org.hamcrest.Matcher<LocalDateTime> isYear(int year)
assertThat(myDate, sameYear(2013))
year - the reference year against which the examined date is checkedpublic static org.hamcrest.Matcher<LocalDateTime> within(long period, ChronoUnit unit, LocalDateTime date)
assertThat(myDate, within(10, TimeUnit.DAYS, Moments.today()))
date - the reference date against which the examined date is checkedpublic static org.hamcrest.Matcher<LocalDateTime> within(long period, ChronoUnit unit, int year, Month month, int dayofMonth, int hour, int minute, int second, int nanos)
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 - hour - the hour of the dayminute - the minute of the hoursecond - the second of the minutehour - the hour of the dayminute - the minute of the hoursecond - the second of the minutenanons - the nanoseconds of the secondpublic static org.hamcrest.Matcher<LocalDateTime> isYesterday()
assertThat(myDate, isToday());
public static org.hamcrest.Matcher<LocalDateTime> isToday()
assertThat(myDate, isToday());
public static org.hamcrest.Matcher<LocalDateTime> isTomorrow()
assertThat(myDate, isTomorrow());
public static org.hamcrest.Matcher<LocalDateTime> sameDayOfWeek(LocalDateTime date)
assertThat(myDate, sameDayOfWeek(LocalDateTime.now()))
date - the reference date against which the examined date is checkedpublic static org.hamcrest.Matcher<LocalDateTime> isDayOfWeek(DayOfWeek... dayOfWeek)
assertThat(myDate, isMonday());
public static org.hamcrest.Matcher<LocalDateTime> isMonday()
assertThat(myDate, isMonday());
public static org.hamcrest.Matcher<LocalDateTime> isTuesday()
assertThat(myDate, isTuesday());
public static org.hamcrest.Matcher<LocalDateTime> isWednesday()
assertThat(myDate, isWednesday());
public static org.hamcrest.Matcher<LocalDateTime> isThursday()
assertThat(myDate, isThursday());
public static org.hamcrest.Matcher<LocalDateTime> isFriday()
assertThat(myDate, isFriday());
public static org.hamcrest.Matcher<LocalDateTime> isSaturday()
assertThat(myDate, isSaturday());
public static org.hamcrest.Matcher<LocalDateTime> isSunday()
assertThat(myDate, isSunday());
public static org.hamcrest.Matcher<LocalDateTime> isWeekday()
assertThat(myDate, isWeekday());
public static org.hamcrest.Matcher<LocalDateTime> isWeekend()
assertThat(myDate, isWeekend());
public static org.hamcrest.Matcher<LocalDateTime> isFirstDayOfMonth()
assertThat(myDate, isFirstDayOfMonth());
public static org.hamcrest.Matcher<LocalDateTime> isMinimum(TemporalField field)
assertThat(myDate, isMaximumDayOfMonth(ChronoField.DAY_OF_MONTH));
field - the temporal field to checkpublic static org.hamcrest.Matcher<LocalDateTime> isLastDayOfMonth()
assertThat(myDate, isFirstDayOfMonth());
public static org.hamcrest.Matcher<LocalDateTime> isMaximum(TemporalField field)
assertThat(myDate, isMaximum(ChronoField.DAY_OF_MONTH));
field - the temporal field to checkpublic static org.hamcrest.Matcher<LocalDateTime> isMonth(Month month)
assertThat(myDate, isMonth(Month.AUGUST));
public static org.hamcrest.Matcher<LocalDateTime> isJanuary()
assertThat(myDate, isJanuary());
public static org.hamcrest.Matcher<LocalDateTime> isFebruary()
assertThat(myDate, isFebruary());
public static org.hamcrest.Matcher<LocalDateTime> isMarch()
assertThat(myDate, isMarch());
public static org.hamcrest.Matcher<LocalDateTime> isApril()
assertThat(myDate, isApril());
public static org.hamcrest.Matcher<LocalDateTime> isMay()
assertThat(myDate, isMay());
public static org.hamcrest.Matcher<LocalDateTime> isJune()
assertThat(myDate, isJune());
public static org.hamcrest.Matcher<LocalDateTime> isJuly()
assertThat(myDate, isJuly());
public static org.hamcrest.Matcher<LocalDateTime> isAugust()
assertThat(myDate, isAugust());
public static org.hamcrest.Matcher<LocalDateTime> isSeptember()
assertThat(myDate, isSeptember());
public static org.hamcrest.Matcher<LocalDateTime> isOctober()
assertThat(myDate, isOctober());
public static org.hamcrest.Matcher<LocalDateTime> isNovember()
assertThat(myDate, isNovember());
public static org.hamcrest.Matcher<LocalDateTime> isDecember()
assertThat(myDate, isDecember());
public static org.hamcrest.Matcher<LocalDateTime> isLeapYear()
assertThat(myDate, isLeapYear());
public static org.hamcrest.Matcher<LocalDateTime> isHour(int hour)
assertThat(myDate, isHour(12));
hour - the hour of the day (0-23)public static org.hamcrest.Matcher<LocalDateTime> sameHourOfDay(LocalDateTime date)
assertThat(myDate, sameHourOfDay(LocalDateTime.now()))
date - the reference date against which the examined date is checkedpublic static org.hamcrest.Matcher<LocalDateTime> isMinute(int minute)
assertThat(myDate, isMinute(12));
Minute - the minute of the day (0-59)public static org.hamcrest.Matcher<LocalDateTime> sameMinuteOfHour(LocalDateTime date)
assertThat(myDate, sameMinuteOfHour(LocalDateTime.now()))
date - the reference date against which the examined date is checkedpublic static org.hamcrest.Matcher<LocalDateTime> isSecond(int Second)
assertThat(myDate, isSecond(12));
Second - the second of the day (0-59)public static org.hamcrest.Matcher<LocalDateTime> sameSecondOfMinute(LocalDateTime date)
assertThat(myDate, sameSecondOfMinute(LocalDateTime.now()))
date - the reference date against which the examined date is checkedCopyright © 2015. All rights reserved.