| Constructor and Description |
|---|
IsWithin(long period,
TimeUnit unit,
Date expected) |
| Modifier and Type | Method and Description |
|---|---|
void |
describeTo(org.hamcrest.Description description) |
protected boolean |
matchesSafely(Date actual,
org.hamcrest.Description mismatchDesc) |
static org.hamcrest.Matcher<Date> |
within(long period,
TimeUnit unit,
Date date)
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,
DayMonthYear date)
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 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:
|
protected boolean matchesSafely(Date actual, org.hamcrest.Description mismatchDesc)
matchesSafely in class org.hamcrest.TypeSafeDiagnosingMatcher<Date>public void describeTo(org.hamcrest.Description description)
public static org.hamcrest.Matcher<Date> within(long period, TimeUnit unit, Date date)
assertThat(myDate, within(10, TimeUnit.MINUTES, new Date()))
period - the timeunit interval the examined date should be withunit - the timeunit to define the length of the perioddate - 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(2, TimeUnit.DAYS, Moments.today()))
period - the timeunit interval the examined date should be withunit - the timeunit to define the length of the perioddate - 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 checkedCopyright © 2014. All Rights Reserved.