Dates.
Note that assertions with date parameter come with two flavors, one is obviously a Date and the other is a
String representing a Date.
For the latter, the default format follows ISO 8901: "yyyy-MM-dd", user can override it with a custom format by
calling withDateFormat(DateFormat).
The user custom format will then be used for all next Date assertions (i.e not limited to the current assertion) in
the test suite.
To turn back to default format, simply call withDefaultDateFormatsOnly().
| Modifier and Type | Field and Description |
|---|---|
| private static final String | |
| private static final String | |
| pack-priv Dates | |
| private static List | DEFAULT_DATE_FORMATS
the default DateFormat used to parse any String date representation. |
| private static boolean | |
| pack-priv static ThreadLocal | userDateFormats
Used in String based Date assertions - like |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| private List | |
| private Date | |
| private static boolean | |
| pack-priv static List | |
| public SELF | Returns: this assertion object.the day of month to compare actual day of month to dayOfMonth)Verifies that the actual |
| public SELF | Returns: this assertion object.the day of week to compare actual day of week to, see dayOfWeek)Calendar#DAY_OF_WEEK for valid
valuesVerifies that the actual |
| public SELF | Returns: this assertion object.the hour of day to compare actual hour of day to (24-hour clock) hourOfDay)Verifies that the actual |
| public SELF | Returns: this assertion object.the millisecond to compare actual millisecond to millisecond)Verifies that the actual |
| public SELF | Returns: this assertion object.the minute to compare actual minute to minute)Verifies that the actual |
| public SELF | Returns: this assertion object.the month to compare actual month to, month value starting at 1 (January=1, February=2, ...). month)Verifies that the actual |
| public SELF | Returns: this assertion object.the date to compare actual time to. date)Verifies that the actual |
| public SELF | Returns: this assertion object.the given dateAsString)Date represented as String in default or custom date format.Verifies that the actual |
| public SELF | Returns: this assertion object.the second to compare actual second to second)Verifies that the actual |
| public SELF | Returns: this assertion object.the timestamp to compare actual time to. timestamp)Verifies that the actual |
| public SELF | Returns: this assertion object.the year to compare actual year to year)Verifies that the actual |
| public SELF | |
| public SELF | |
| public SELF | Returns: this assertion object.the given Date represented as String in default or custom date format. dateAsString)Same assertion as |
| public SELF | Returns: this assertion object.the given Date. other)
Deprecated
prefer calling
Verifies that the actual isAfterOrEqualTo(Date)
Date is after or equals to the given one.
|
| public SELF | Returns: this assertion object.the given Date represented as String in default or custom date format. dateAsString)
Deprecated
prefer calling
Same assertion as isAfterOrEqualTo(String)
isAfterOrEqualsTo(Date) but given date is represented as String either with one of the
supported default date formats or a user custom date format (set with method withDateFormat(DateFormat)).
|
| public SELF | Returns: this assertion object.the given Date. other)Verifies that the actual |
| public SELF | Returns: this assertion object.the given other)Instant.Verifies that the actual |
| public SELF | Returns: this assertion object.the given Date represented as String in default or custom date format. dateAsString)Same assertion as |
| public SELF | Returns: this assertion object.the year to compare actual year to year)Verifies that the actual |
| public SELF | |
| public SELF | |
| public SELF | Returns: this assertion object.the given Date represented as String in default or custom date format. dateAsString)Same assertion as |
| public SELF | Returns: this assertion object.the given Date. other)
Deprecated
prefer calling
Verifies that the actual isBeforeOrEqualTo(Date)
Date is before or equals to the given one.
|
| public SELF | Returns: this assertion object.the given Date represented as String in default or custom date format. dateAsString)
Deprecated
prefer calling
Same assertion as isBeforeOrEqualTo(String)
isBeforeOrEqualsTo(Date) but given date is represented as String either with one of the
supported default date formats or a user custom date format (set with method withDateFormat(DateFormat)).
|
| public SELF | Returns: this assertion object.the given Date. other)Verifies that the actual |
| public SELF | Returns: this assertion object.the given other)Instant.Verifies that the actual |
| public SELF | Returns: this assertion object.the given Date represented as String in default or custom date format. dateAsString)Same assertion as |
| public SELF | Returns: this assertion object.the year to compare actual year to year)Verifies that the actual |
| public SELF | |
| public SELF | Returns: this assertion object.the period start (inclusive), expected not to be null. start, String the period end (exclusive), expected not to be null. end)Same assertion as |
| public SELF | Returns: this assertion object.the period start (inclusive), expected not to be null. start, Instant the period end (exclusive), expected not to be null. end)Same assertion as |
| public SELF | Returns: this assertion object.the period start, expected not to be null. start, Date the period end, expected not to be null. end, boolean whether to include start date in period. inclusiveStart, boolean whether to include end date in period. inclusiveEnd)Verifies that the actual |
| public SELF | Returns: this assertion object.the period start, expected not to be null. start, String the period end, expected not to be null. end, boolean whether to include start date in period. inclusiveStart, boolean whether to include end date in period. inclusiveEnd)Same assertion as |
| public SELF | Returns: this assertion object.the period start, expected not to be null. start, Instant the period end, expected not to be null. end, boolean whether to include start date in period. inclusiveStart, boolean whether to include end date in period. inclusiveEnd)Same assertion as |
| public SELF | Returns: this assertion object.the date to compare actual to other, long the delta used for date comparison, expressed in milliseconds deltaInMilliseconds)Verifies that the actual |
| public SELF | Returns: this assertion object.the Instant to compare actual to other, long the delta used for date comparison, expressed in milliseconds deltaInMilliseconds)Verifies that the actual |
| public SELF | Returns: this assertion object.the given Date represented as String in default or custom date format. dateAsString, long the delta used for date comparison, expressed in milliseconds deltaInMilliseconds)Same assertion as |
| public SELF | Returns: this assertion object.the given Date represented as String in default or custom date format. dateAsString)Same assertion as |
| public SELF | Returns: this assertion object.the given instant)Instant to compare to actual.Calls |
| public SELF | Returns: this assertion object.the given Date represented as String in default or custom date format. dateAsString)
Deprecated
Use
Same assertion as isCloseTo(Date, long) instead, although not exactly the same semantics,
this is the right way to compare with a given precision.
AbstractDateAssert#isEqualToIgnoringHours(Date) but given Date is represented as String
either with one of the default supported date formats or user custom date format (set with method
withDateFormat(DateFormat)).
|
| public SELF | Returns: this assertion object.the given instant)Instant.
Deprecated
Use
Same assertion as isCloseTo(Instant, long) instead, although not exactly the same semantics,
this is the right way to compare with a given precision.
AbstractDateAssert#isEqualToIgnoringHours(Date) but given Date is represented as
an java.time.Instant.
|
| public SELF | Returns: this assertion object.the given Date. date)
Deprecated
Use
Same assertion as isCloseTo(Date, long) instead, although not exactly the same semantics,
this is the right way to compare with a given precision.
AbstractAssert#isEqualTo(Object) but the comparison ignores hours, minutes, seconds and milliseconds.
|
| public SELF | Returns: this assertion object.the given Date represented as String in default or custom date format. dateAsString)
Deprecated
Use
Same assertion as isCloseTo(Date, long) instead, although not exactly the same semantics,
this is the right way to compare with a given precision.
AbstractDateAssert#isEqualToIgnoringMillis(Date) but given Date is represented as String
either with one of the default supported date formats or user custom date format (set with method
withDateFormat(DateFormat)).
|
| public SELF | Returns: this assertion object.the given instant)Instant.
Deprecated
Use
Same assertion as isCloseTo(Instant, long) instead, although not exactly the same semantics,
this is the right way to compare with a given precision.
AbstractDateAssert#isEqualToIgnoringMillis(Date) but given Date is represented as
an java.time.Instant.
|
| public SELF | Returns: this assertion object.the given Date represented as String in default or custom date format. date)
Deprecated
Use
Same assertion as isCloseTo(Date, long) instead, although not exactly the same semantics,
this is the right way to compare with a given precision.
AbstractAssert#isEqualTo(Object) but given Date should not take care of milliseconds
precision.
|
| public SELF | Returns: this assertion object.the given Date represented as String in default or custom date format. dateAsString)
Deprecated
Use
Same assertion as isCloseTo(Date, long) instead, although not exactly the same semantics,
this is the right way to compare with a given precision.
AbstractDateAssert#isEqualToIgnoringMinutes(Date) but given Date is represented as
String either with one of the default supported date format or user custom date format (set with method
withDateFormat(DateFormat)).
|
| public SELF | Returns: this assertion object.the given instant)Instant.
Deprecated
Use
Same assertion as isCloseTo(Instant, long) instead, although not exactly the same semantics,
this is the right way to compare with a given precision.
AbstractDateAssert#isEqualToIgnoringMinutes(Date) but given Date is represented as
an java.time.Instant.
|
| public SELF | Returns: this assertion object.the given Date. date)
Deprecated
Use
Same assertion as isCloseTo(Date, long) instead, although not exactly the same semantics,
this is the right way to compare with a given precision.
AbstractAssert#isEqualTo(Object) but given Date should not take care of minutes,
seconds and millisecond precision.
|
| public SELF | Returns: this assertion object.the given Date represented as String in default or custom date format. dateAsString)
Deprecated
Use
Same assertion as isCloseTo(Date, long) instead, although not exactly the same semantics,
this is the right way to compare with a given precision.
AbstractDateAssert#isEqualToIgnoringSeconds(Date) but given Date is represented as
String
either with one of the default supported date formats or user custom date format (set with method
withDateFormat(DateFormat)).
|
| public SELF | Returns: this assertion object.the given instant)Instant.
Deprecated
Use
Same assertion as isCloseTo(Instant, long) instead, although not exactly the same semantics,
this is the right way to compare with a given precision.
AbstractDateAssert#isEqualToIgnoringSeconds(Date) but given Date is represented as
an java.time.Instant.
|
| public SELF | Returns: this assertion object.the given Date represented as String in default or custom date format. date)
Deprecated
Use
Same assertion as isCloseTo(Date, long) instead, although not exactly the same semantics,
this is the right way to compare with a given precision.
AbstractAssert#isEqualTo(Object) but given Date should not take care of seconds and
millisecond precision.
|
| public SELF | Returns: this assertion object.the given Dates represented as String in default or custom date format. datesAsString)Same assertion as |
| public SELF | Returns: this assertion object.the given dates represented as instants)Instant.Same assertion as |
| public SELF | Returns: this assertion object.the given other)Date to compare actual Date to.Verifies that actual and given |
| public SELF | Returns: this assertion object.the given other)Date to compare actual Date to.Verifies that actual |
| public SELF | Returns: this assertion object.the given Date represented as String in default or custom date format. dateAsString)Same assertion as |
| public SELF | Returns: this assertion object.the given other)Date to compare actual Date to.
Deprecated
Use
Verifies that actual and given isCloseTo(Date, long) instead, although not exactly the same semantics,
this is the right way to compare with a given precision.
Date have same hour, day, month and year fields values.
|
| public SELF | Returns: this assertion object.the given Date represented as String in default or custom date format. dateAsString)
Deprecated
Use
Same assertion as isCloseTo(Date, long) instead, although not exactly the same semantics,
this is the right way to compare with a given precision.
isInSameHourAs(Date) but given date is represented as String either with one of the
supported default date formats or a user custom date format (set with method withDateFormat(DateFormat)).
|
| public SELF | Returns: this assertion object.the given other)Date to compare actual Date to.Verifies that actual and given |
| public SELF | Returns: this assertion object.the given other)Instant to compare actual Date to.Verifies that actual |
| public SELF | Returns: this assertion object.the given Date represented as String in default or custom date format. dateAsString)Same assertion as |
| public SELF | Returns: this assertion object.the given other)Date to compare actual Date to.
Deprecated
Use
Verifies that actual and given isCloseTo(Date, long) instead, although not exactly the same semantics,
this is the right way to compare with a given precision.
Date have same minute, same hour, day, month and year fields values.
|
| public SELF | Returns: this assertion object.the given Date represented as String in default or custom date format. dateAsString)
Deprecated
Use
Same assertion as isCloseTo(Date, long) instead, although not exactly the same semantics,
this is the right way to compare with a given precision.
isInSameMinuteAs(Date) but given date is represented as String either with one of the
supported default date formats or a user custom date format (set with method withDateFormat(DateFormat)).
|
| public SELF | Returns: this assertion object.the given other)Date to compare actual Date to.Verifies that actual and given |
| public SELF | Returns: this assertion object.the given other)Instant to compare actual Date to.Verifies that actual |
| public SELF | Returns: this assertion object.the given Date represented as String in default or custom date format. dateAsString)Same assertion as |
| public SELF | Returns: this assertion object.the given other)Date to compare actual Date to.Verifies that actual and given |
| public SELF | Returns: this assertion object.the given other)Instant to compare actual Date to.Verifies that actual |
| public SELF | Returns: this assertion object.the given Date represented as String in default or custom date format. dateAsString)Same assertion as |
| public SELF | Returns: this assertion object.the given other)Date to compare actual Date to.
Deprecated
Use
Verifies that actual and given isCloseTo(Date, long) instead, although not exactly the same semantics,
this is the right way to compare with a given precision.
Date have same second, minute, hour, day, month and year fields values.
|
| public SELF | Returns: this assertion object.the given Date represented as String. dateAsString)
Deprecated
Use
Same assertion as isCloseTo(Date, long) instead, although not exactly the same semantics,
this is the right way to compare with a given precision.
isInSameSecondAs(Date) but given date is represented as String either with one of the
supported defaults date format or a user custom date format (set with method withDateFormat(DateFormat)).
|
| public SELF | Returns: this assertion object.the given other)Date to compare actual Date to.Verifies that actual and given |
| public SELF | Returns: this assertion object.the given other)Instant to compare actual Date to.Verifies that actual |
| public SELF | Returns: this assertion object.the given Date represented as String. dateAsString)Same assertion as |
| public SELF | Returns: this assertion object.the given other)Date to compare actual Date to.Verifies that actual and given |
| public SELF | Returns: this assertion object.the given other)Instant to compare actual Date to.Verifies that actual |
| public SELF | Returns: this assertion object.the given Date represented as String in default or custom date format. dateAsString)Same assertion as |
| public SELF | Returns: this assertion object.Verifies that the actual |
| public SELF | |
| public SELF | Returns: this assertion object.the given Dates represented as String in default or custom date format. datesAsString)Same assertion as |
| public SELF | Returns: this assertion object.the period start (inclusive), expected not to be null. start, Date the period end (exclusive), expected not to be null. end, boolean whether to include start date in period. inclusiveStart, boolean whether to include end date in period. inclusiveEnd)Verifies that the actual |
| public SELF | Returns: this assertion object.the period start (inclusive), expected not to be null. start, Instant the period end (exclusive), expected not to be null. end, boolean whether to include start date in period. inclusiveStart, boolean whether to include end date in period. inclusiveEnd)Verifies that the actual |
| public SELF | Returns: this assertion object.the period start (inclusive), expected not to be null. start, String the period end (exclusive), expected not to be null. end, boolean whether to include start date in period. inclusiveStart, boolean whether to include end date in period. inclusiveEnd)Same assertion as |
| public SELF | Returns: this assertion object.the period start (inclusive), expected not to be null. start, Date the period end (exclusive), expected not to be null. end)Verifies that the actual Example:
|
| public SELF | Returns: this assertion object.the period start (inclusive), expected not to be null. start, Instant the period end (exclusive), expected not to be null. end)Verifies that the actual Example:
|
| public SELF | Returns: this assertion object.the period start (inclusive), expected not to be null. start, String the period end (exclusive), expected not to be null. end)Same assertion as |
| public SELF | Returns: this assertion object.the given Date represented as String in default or custom date format. dateAsString)Same assertion as |
| public SELF | Returns: this assertion object.the given instant)Instant.Same assertion as |
| public SELF | Returns: this assertion object.the given Dates represented as String in default or custom date format. datesAsString)Same assertion as |
| public SELF | Returns: this assertion object.the given dates represented as instants)Instant.Same assertion as |
| public SELF | Returns: this assertion object.the given Dates represented as String in default or custom date format. datesAsString)Same assertion as |
| public SELF | Returns: this assertion object.Verifies that the actual |
| public SELF | Returns: this assertion object.the day of month to compare actual day of month to dayOfMonth)
Deprecated
use
hasDayOfMonth(int) instead.
|
| public SELF | Returns: this assertion object.the day of week to compare actual day of week to, see dayOfWeek)Calendar#DAY_OF_WEEK for valid
values
Deprecated
use
hasDayOfWeek(int) instead.
|
| public SELF | Returns: this assertion object.the hour of day to compare actual hour of day to (24-hour clock) hourOfDay)
Deprecated
use
hasHourOfDay(int) instead.
|
| public SELF | Returns: this assertion object.the millisecond to compare actual millisecond to millisecond)
Deprecated
use
hasMillisecond(int) instead.
|
| public SELF | Returns: this assertion object.the minute to compare actual minute to minute)
Deprecated
use
hasMinute(int) instead.
|
| public SELF | Returns: this assertion object.the month to compare actual month to, month value starting at 1 (January=1, February=2, ...). month)
Deprecated
use
hasMonth(int) instead.
|
| public SELF | Returns: this assertion object.the second to compare actual second to second)
Deprecated
use
hasSecond(int) instead.
|
| public SELF | Returns: this assertion object.the year to compare actual year to year)
Deprecated
use
hasYear(int) instead.
|
| pack-priv Date | Returns: the corresponding Date, null if dateAsString parameter is null.the string to parse as a Date with dateAsString)userDateFormatsThread safe utility method to parse a Date with |
| private Date | |
| private synchronized Date | |
| public static void | registerCustomDateFormat(DateFormat
the new Date format used for String based Date assertions. userCustomDateFormat)Add the given date format to the ones used to parse date String in String based Date assertions like
|
| public static void | registerCustomDateFormat(String
the new Date format pattern used for String based Date assertions. userCustomDateFormatPattern)Add the given date format to the ones used to parse date String in String based Date assertions like
|
| public static void | setLenientDateParsing(boolean
whether lenient parsing mode should be enabled or not lenientDateParsing)Instead of using default strict date/time parsing, it is possible to use lenient parsing mode for default date formats parser to interpret inputs that do not precisely match supported date formats (lenient parsing). |
| private static <T> Date[] | |
| public static void | useDefaultDateFormatsOnly()
Remove all registered custom date formats => use only the defaults date formats to parse string as date. |
| public SELF | usingComparator(Comparator<? super Date>
the comparator to use for the incoming assertion checks. customComparator)Overrides org. Implements org. |
| public SELF | usingComparator(Comparator<? super Date>
the comparator to use for the incoming assertion checks. customComparator, String comparator description to be used in assertion error messages customComparatorDescription)Overrides org. Implements org. |
| public SELF | usingDefaultComparator()
Overrides org. Implements org. |
| public SELF | Returns: this assertion object.the new Date format used for String based Date assertions. userCustomDateFormat)Instead of using default date formats for the date String based Date assertions like |
| public SELF | Returns: this assertion object.the new Date format string pattern used for String based Date assertions. userCustomDateFormatPattern)Instead of using default date formats for the date String based Date assertions like |
| public SELF | Returns: this assertionRemove all registered custom date formats => use only the default date formats to parse string as date. |