public abstract class DateMatchers extends Object
Matcher instances for comparing dates| Constructor and Description |
|---|
DateMatchers() |
| Modifier and Type | Method and Description |
|---|---|
static org.hamcrest.Matcher<Date> |
after(Date date)
Creates a matcher that matches when the examined date is after the reference date
For example:
|
static org.hamcrest.Matcher<Date> |
after(DayMonthYear date)
Creates a matcher that matches when the examined date is after the reference date
For example:
|
static org.hamcrest.Matcher<Date> |
after(int year,
Months month,
int day)
Creates a matcher that matches when the examined date is after the end of the reference year
For example:
|
static org.hamcrest.Matcher<Date> |
after(int year,
Months month,
int date,
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<Date> |
before(Date date)
Creates a matcher that matches when the examined date is before the reference date
For example:
|
static org.hamcrest.Matcher<Date> |
before(DayMonthYear date)
Creates a matcher that matches when the examined date is before the reference date
For example:
|
static org.hamcrest.Matcher<Date> |
before(int year,
Months month,
int day)
Creates a matcher that matches when the examined date is before the start of reference day
For example:
|
static org.hamcrest.Matcher<Date> |
before(int year,
Months month,
int date,
int hour,
int minute,
int second)
Creates a matcher that matches when the examined date is before the start of the reference date and time
For example:
|
static org.hamcrest.Matcher<Date> |
isApril()
Creates a matcher that matches when the examined date is in April
For example:
|
static org.hamcrest.Matcher<Date> |
isAugust()
Creates a matcher that matches when the examined date is in August
For example:
|
static org.hamcrest.Matcher<Date> |
isDecember()
Creates a matcher that matches when the examined date is in December
For example:
|
static org.hamcrest.Matcher<Date> |
isFebruary()
Creates a matcher that matches when the examined date is in February
For example:
|
static org.hamcrest.Matcher<Date> |
isFirstDayOfMonth()
Creates a matcher that matches when the examined date is on the first day of the month
For example:
|
static org.hamcrest.Matcher<Date> |
isFriday()
Creates a matcher that matches when the examined date is on a friday
For example:
|
static org.hamcrest.Matcher<Date> |
isJanuary()
Creates a matcher that matches when the examined date is in January
For example:
|
static org.hamcrest.Matcher<Date> |
isJuly()
Creates a matcher that matches when the examined date is in July
For example:
|
static org.hamcrest.Matcher<Date> |
isJune()
Creates a matcher that matches when the examined date is in June
For example:
|
static org.hamcrest.Matcher<Date> |
isLastDayOfMonth()
Creates a matcher that matches when the examined date is on the first day of the month
For example:
|
static org.hamcrest.Matcher<Date> |
isLeapYear()
Creates a matcher that matches when the examined date is a leap year
For example:
|
static org.hamcrest.Matcher<Date> |
isMarch()
Creates a matcher that matches when the examined date is in March
For example:
|
static org.hamcrest.Matcher<Date> |
isMay()
Creates a matcher that matches when the examined date is in May
For example:
|
static org.hamcrest.Matcher<Date> |
isMonday()
Creates a matcher that matches when the examined date is on a monday
For example:
|
static org.hamcrest.Matcher<Date> |
isNovember()
Creates a matcher that matches when the examined date is in November
For example:
|
static org.hamcrest.Matcher<Date> |
isOctober()
Creates a matcher that matches when the examined date is in October
For example:
|
static org.hamcrest.Matcher<Date> |
isSaturday()
Creates a matcher that matches when the examined date is on a saturday
For example:
|
static org.hamcrest.Matcher<Date> |
isSeptember()
Creates a matcher that matches when the examined date is in September
For example:
|
static org.hamcrest.Matcher<Date> |
isSunday()
Creates a matcher that matches when the examined date is on a sunday
For example:
|
static org.hamcrest.Matcher<Date> |
isThursday()
Creates a matcher that matches when the examined date is on a thursday
For example:
|
static org.hamcrest.Matcher<Date> |
isToday()
Creates a matcher that matches when the examined date is today
For example:
|
static org.hamcrest.Matcher<Date> |
isTomorrow()
Creates a matcher that matches when the examined date is tomorrow
For example:
|
static org.hamcrest.Matcher<Date> |
isTuesday()
Creates a matcher that matches when the examined date is on a tuesday
For example:
|
static org.hamcrest.Matcher<Date> |
isWednesday()
Creates a matcher that matches when the examined date is on a wednesday
For example:
|
static org.hamcrest.Matcher<Date> |
isWeekday()
Creates a matcher that matches when the examined date is on a weekday
For example:
|
static org.hamcrest.Matcher<Date> |
isWeekend()
Creates a matcher that matches when the examined date is on a weekend
For example:
|
static org.hamcrest.Matcher<Date> |
isYesterday()
Creates a matcher that matches when the examined date is yesterday
For example:
|
static org.hamcrest.Matcher<Date> |
sameDay(Date 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<Date> |
sameDay(DayMonthYear 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<Date> |
sameDay(int year,
Months month,
int day)
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<Date> |
sameDayOfWeek(Date 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<Date> |
sameDayOfWeek(Weekdays weekday)
Creates a matcher that matches when the examined date is on the same day of the week as the supplied day
For example:
|
static org.hamcrest.Matcher<Date> |
sameHour(Date 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<Date> |
sameHour(int hour)
Creates a matcher that matches when the examined date is on the same hour as the reference date
For example:
|
static org.hamcrest.Matcher<Date> |
sameInstant(Date date)
Creates a matcher that matches when the examined date is on the same instant as the reference date
For example:
|
static org.hamcrest.Matcher<Date> |
sameInstant(int year,
Months month,
int date,
int hour,
int minute,
int second,
int milliseconds)
Creates a matcher that matches when the examined date is on the same instance as the reference date
For example:
|
static org.hamcrest.Matcher<Date> |
sameInstant(long timestamp)
Creates a matcher that matches when the examined date is on the same UTC instant as the reference UTC epoch time supplied
For example:
|
static org.hamcrest.Matcher<Date> |
sameMillisecond(Date date)
Creates a matcher that matches when the examined date is on the same millisecond as the reference date
For example:
|
static org.hamcrest.Matcher<Date> |
sameMillisecond(int millisecond)
Creates a matcher that matches when the examined date is on the reference second
For example:
|
static org.hamcrest.Matcher<Date> |
sameMinute(Date 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<Date> |
sameMinute(int minute)
Creates a matcher that matches when the examined date is on the reference minute
For example:
|
static org.hamcrest.Matcher<Date> |
sameMonth(Date 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<Date> |
sameMonth(Months month)
Creates a matcher that matches when the examined date is on the same month as the reference month
For example:
|
static org.hamcrest.Matcher<Date> |
sameOrAfter(Date 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<Date> |
sameOrAfter(DayMonthYear 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<Date> |
sameOrAfter(int year,
Months month,
int day)
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<Date> |
sameOrAfter(int year,
Months month,
int date,
int hour,
int minute,
int second)
Creates a matcher that matches when the examined date is on the same second or after the start of the reference date and time
For example:
|
static org.hamcrest.Matcher<Date> |
sameOrBefore(Date 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<Date> |
sameOrBefore(DayMonthYear date)
Creates a matcher that matches when the examined date is at the same date or before the reference date
For example:
|
static org.hamcrest.Matcher<Date> |
sameOrBefore(int year,
Months month,
int day)
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<Date> |
sameOrBefore(int year,
Months month,
int date,
int hour,
int minute,
int second)
Creates a matcher that matches when the examined date is on the same second or before the start of the reference date and time
For example:
|
static org.hamcrest.Matcher<Date> |
sameSecond(Date 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<Date> |
sameSecond(int second)
Creates a matcher that matches when the examined date is on the reference second
For example:
|
static org.hamcrest.Matcher<Date> |
sameWeekday(Date date)
Deprecated.
|
static org.hamcrest.Matcher<Date> |
sameWeekday(Weekdays weekday)
Deprecated.
|
static org.hamcrest.Matcher<Date> |
sameYear(Date 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<Date> |
sameYear(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<Date> |
within(long period,
TimeUnit unit,
Date date)
Creates a matcher that matches when the examined date is within a defined period the reference date
For example:
|
static org.hamcrest.Matcher<Date> |
within(long period,
TimeUnit unit,
DayMonthYear date)
Creates a matcher that matches when the examined date is within a defined period the reference date
For example:
|
static org.hamcrest.Matcher<Date> |
within(long period,
TimeUnit unit,
int year,
Months month,
int day)
Creates a matcher that matches when the examined date is within a given period of the reference date
For example:
|
static org.hamcrest.Matcher<Date> |
within(long period,
TimeUnit unit,
int year,
Months month,
int date,
int hour,
int minute,
int second,
int milliseconds)
Creates a matcher that matches when the examined date is within a given period of the reference date
For example:
|
public static org.hamcrest.Matcher<Date> after(Date date)
assertThat(myDate, after(new Date()))
date - the reference date against which the examined date is checkedpublic static org.hamcrest.Matcher<Date> after(DayMonthYear date)
assertThat(myDate, after(Moments.today()))
date - the reference date against which the examined date is checkedpublic static org.hamcrest.Matcher<Date> after(int year, Months month, int day)
assertThat(myDate, after(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 checkedpublic static org.hamcrest.Matcher<Date> after(int year, Months month, int date, int hour, int minute, int second)
assertThat(myDate, after(2012, Months.MAY, 12, 23, 00, 01));
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 day against which the examined date is checkedminute - the minute of the hour against which the examined date is checkedsecond - the second of the minute against which the examined date is checkedpublic static org.hamcrest.Matcher<Date> before(Date date)
assertThat(myDate, before(new Date()))
date - the reference date against which the examined date is checkedpublic static org.hamcrest.Matcher<Date> before(DayMonthYear date)
assertThat(myDate, before(Moments.today()));
date - the reference date against which the examined date is checkedpublic static org.hamcrest.Matcher<Date> before(int year, Months month, int day)
assertThat(myDate, before(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 checkedpublic static org.hamcrest.Matcher<Date> before(int year, Months month, int date, int hour, int minute, int second)
assertThat(myDate, before(2012, Months.MAY, 12, 23, 00, 01));
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 day against which the examined date is checkedminute - the minute of the hour against which the examined date is checkedsecond - the second of the minute against which the examined date is checked@Deprecated public static org.hamcrest.Matcher<Date> sameWeekday(Date date)
sameDayOfWeek(Date)assertThat(myDate, sameWeekday(new Date()))
date - the reference date against which the examined date is checked@Deprecated public static org.hamcrest.Matcher<Date> sameWeekday(Weekdays weekday)
sameDayOfWeek(Weekdays)assertThat(myDate, sameDayOfTheWeek(Weekdays.MONDAY))
weekday - the reference weekday against which the examined date is checkedpublic static org.hamcrest.Matcher<Date> sameDayOfWeek(Date date)
assertThat(myDate, sameWeekday(new Date()))
date - the reference date against which the examined date is checkedpublic static org.hamcrest.Matcher<Date> sameDayOfWeek(Weekdays weekday)
assertThat(myDate, sameDayOfTheWeek(new Date()))
weekday - the reference weekday against which the examined date is checkedpublic static org.hamcrest.Matcher<Date> sameDay(Date date)
assertThat(myDate, sameDay(new Date()))
date - the reference date against which the examined date is checkedpublic static org.hamcrest.Matcher<Date> sameDay(DayMonthYear date)
assertThat(myDate, sameDay(Moments.today()));
date - the reference date against which the examined date is checkedpublic static org.hamcrest.Matcher<Date> sameDay(int year, Months month, int day)
assertThat(myDate, sameDayOfTheYear(2012, Month.JAN, 1))
day - 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<Date> sameHour(Date date)
assertThat(myDate, sameHour(new Date()))
date - the reference date against which the examined date is checkedpublic static org.hamcrest.Matcher<Date> sameHour(int hour)
assertThat(myDate, sameHour(12));
hour - the reference hour against which the examined date is checkedpublic static org.hamcrest.Matcher<Date> sameInstant(Date date)
assertThat(myDate, sameInstant(new Date()))
date - the reference date against which the examined date is checkedpublic static org.hamcrest.Matcher<Date> sameInstant(long timestamp)
assertThat(myDate, sameInstant(1325415600000L))
timestamp - the time as milliseconds since the Unix epoch timepublic static org.hamcrest.Matcher<Date> sameInstant(int year, Months month, int date, int hour, int minute, int second, int milliseconds)
assertThat(myDate, sameInstant(2012, Months.MAY, 12, 23, 00, 01, 123));
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 day against which the examined date is checkedminute - the minute of the hour against which the examined date is checkedsecond - the second of the minute against which the examined date is checkedmilliseconds - the milliseconds of the second against which the examined date is checkedpublic static org.hamcrest.Matcher<Date> sameOrBefore(Date date)
assertThat(myDate, isSameOrBefore(new Date()))
date - the reference date against which the examined date is checkedpublic static org.hamcrest.Matcher<Date> sameOrBefore(DayMonthYear date)
assertThat(myDate, isSameOrBefore(new Date()))
date - the reference date against which the examined date is checkedpublic static org.hamcrest.Matcher<Date> sameOrBefore(int year, Months month, int day)
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 checkedpublic static org.hamcrest.Matcher<Date> sameOrBefore(int year, Months month, int date, int hour, int minute, int second)
assertThat(myDate, isSameOrBefore(2012, Months.MAY, 12, 23, 00, 01));
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 day against which the examined date is checkedminute - the minute of the hour against which the examined date is checkedsecond - the second of the minute against which the examined date is checkedpublic static org.hamcrest.Matcher<Date> sameOrAfter(Date date)
assertThat(myDate, isSameOrAfter(new Date()))
date - the reference date against which the examined date is checkedpublic static org.hamcrest.Matcher<Date> sameOrAfter(DayMonthYear date)
assertThat(myDate, isSameOrAfter(Moments.today()))
date - the reference date against which the examined date is checkedpublic static org.hamcrest.Matcher<Date> sameOrAfter(int year, Months month, int day)
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 checkedpublic static org.hamcrest.Matcher<Date> sameOrAfter(int year, Months month, int date, int hour, int minute, int second)
assertThat(myDate, isSameOrAfter(2012, Months.MAY, 12, 23, 00, 01));
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 day against which the examined date is checkedminute - the minute of the hour against which the examined date is checkedsecond - the second of the minute against which the examined date is checkedpublic static org.hamcrest.Matcher<Date> sameMinute(Date date)
assertThat(myDate, sameMinute(new Date()))
date - the reference date against which the examined date is checkedpublic static org.hamcrest.Matcher<Date> sameMinute(int minute)
assertThat(myDate, sameMinute(55))
minute - the reference minute against which the examined date is checkedpublic static org.hamcrest.Matcher<Date> sameMonth(Date date)
assertThat(myDate, sameMonth(new Date()))
date - the reference date against which the examined date is checkedpublic static org.hamcrest.Matcher<Date> sameMonth(Months month)
assertThat(myDate, sameMonth(Months.DECEMBER))
month - the reference month against which the examined date is checkedpublic static org.hamcrest.Matcher<Date> sameSecond(Date date)
assertThat(myDate, sameSecond(new Date()))
date - the reference date against which the examined date is checkedpublic static org.hamcrest.Matcher<Date> sameSecond(int second)
assertThat(myDate, sameSecond(33))
second - the reference date against which the examined date is checkedpublic static org.hamcrest.Matcher<Date> sameMillisecond(Date date)
assertThat(myDate, sameMillisecond(new Date()))
date - the reference date against which the examined date is checkedpublic static org.hamcrest.Matcher<Date> sameMillisecond(int millisecond)
assertThat(myDate, sameMillisecond(123))
millisecond - the millisecond against which the examined date is checkedpublic static org.hamcrest.Matcher<Date> sameYear(Date date)
assertThat(myDate, sameYear(new Date()))
date - the reference date against which the examined date is checkedpublic static org.hamcrest.Matcher<Date> sameYear(int year)
assertThat(myDate, sameYear(2013))
year - the reference year against which the examined date is checkedpublic static org.hamcrest.Matcher<Date> within(long period, TimeUnit unit, Date date)
assertThat(myDate, within(10, TimeUnit.MINUTES, new Date()))
date - the reference date against which the examined date is checkedpublic static org.hamcrest.Matcher<Date> within(long period, TimeUnit unit, DayMonthYear date)
assertThat(myDate, within(10, TimeUnit.DAYS, Moments.today()))
date - the reference date against which the examined date is checkedpublic static org.hamcrest.Matcher<Date> within(long period, TimeUnit unit, int year, Months month, int day)
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 checkedday - the day of the month against which the examined date is checkedpublic static org.hamcrest.Matcher<Date> within(long period, TimeUnit unit, int year, Months month, int date, int hour, int minute, int second, int milliseconds)
assertThat(myDate, within(1, TimeUnit.MINUTES, 2012, Months.MAY, 12, 23, 00, 01));
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 checkedday - the day of the month against which the examined date is checkedhour - the hour of the day against which the examined date is checkedminute - the minute of the hour against which the examined date is checkedsecond - the second of the minute against which the examined date is checkedsecond - the millisecond of the second against which the examined date is checkedpublic static org.hamcrest.Matcher<Date> isYesterday()
assertThat(myDate, isToday());
public static org.hamcrest.Matcher<Date> isToday()
assertThat(myDate, isToday());
public static org.hamcrest.Matcher<Date> isTomorrow()
assertThat(myDate, isTomorrow());
public static org.hamcrest.Matcher<Date> isMonday()
assertThat(myDate, isMonday());
public static org.hamcrest.Matcher<Date> isTuesday()
assertThat(myDate, isTuesday());
public static org.hamcrest.Matcher<Date> isWednesday()
assertThat(myDate, isWednesday());
public static org.hamcrest.Matcher<Date> isThursday()
assertThat(myDate, isThursday());
public static org.hamcrest.Matcher<Date> isFriday()
assertThat(myDate, isFriday());
public static org.hamcrest.Matcher<Date> isSaturday()
assertThat(myDate, isSaturday());
public static org.hamcrest.Matcher<Date> isSunday()
assertThat(myDate, isSunday());
public static org.hamcrest.Matcher<Date> isWeekday()
assertThat(myDate, isWeekday());
public static org.hamcrest.Matcher<Date> isWeekend()
assertThat(myDate, isWeekend());
public static org.hamcrest.Matcher<Date> isFirstDayOfMonth()
assertThat(myDate, isFirstDayOfMonth());
public static org.hamcrest.Matcher<Date> isLastDayOfMonth()
assertThat(myDate, isFirstDayOfMonth());
public static org.hamcrest.Matcher<Date> isJanuary()
assertThat(myDate, isJanuary());
public static org.hamcrest.Matcher<Date> isFebruary()
assertThat(myDate, isFebruary());
public static org.hamcrest.Matcher<Date> isMarch()
assertThat(myDate, isMarch());
public static org.hamcrest.Matcher<Date> isApril()
assertThat(myDate, isApril());
public static org.hamcrest.Matcher<Date> isMay()
assertThat(myDate, isMay());
public static org.hamcrest.Matcher<Date> isJune()
assertThat(myDate, isJune());
public static org.hamcrest.Matcher<Date> isJuly()
assertThat(myDate, isJuly());
public static org.hamcrest.Matcher<Date> isAugust()
assertThat(myDate, isAugust());
public static org.hamcrest.Matcher<Date> isSeptember()
assertThat(myDate, isSeptember());
public static org.hamcrest.Matcher<Date> isOctober()
assertThat(myDate, isOctober());
public static org.hamcrest.Matcher<Date> isNovember()
assertThat(myDate, isNovember());
public static org.hamcrest.Matcher<Date> isDecember()
assertThat(myDate, isDecember());
public static org.hamcrest.Matcher<Date> isLeapYear()
assertThat(myDate, isLeapYear());
Copyright © 2014. All Rights Reserved.