Top Description Fields Constructors Methods
org.assertj.core.api

public abstract Class AbstractOffsetTimeAssert<SELF extends AbstractOffsetTimeAssert<SELF>>

extends AbstractTemporalAssert<SELF extends AbstractOffsetTimeAssert<SELF>, OffsetTime>
Class Inheritance
Known Direct Subclasses
org.assertj.core.api.OffsetTimeAssert
Static Imports
org.assertj.core.error.ShouldBeAfter.shouldBeAfter, .ShouldBeAfterOrEqualTo.shouldBeAfterOrEqualTo, .ShouldBeBefore.shouldBeBefore, .ShouldBeBeforeOrEqualTo.shouldBeBeforeOrEqualTo, .ShouldBeEqualIgnoringNanos.shouldBeEqualIgnoringNanos, .ShouldBeEqualIgnoringSeconds.shouldBeEqualIgnoringSeconds, .ShouldBeEqualIgnoringTimezone.shouldBeEqualIgnoringTimezone, .ShouldHaveSameHourAs.shouldHaveSameHourAs, org.assertj.core.util.Preconditions.checkArgument

Assertions for java.time.OffsetTime type from new Date & Time API introduced in Java 8.
Author
Alexander Bischof

Field Summary

Modifier and TypeField and Description
public static final String
Inherited from org.assertj.core.api.AbstractTemporalAssert:
comparables

Constructor Summary

AccessConstructor and Description
protected
AbstractOffsetTimeAssert(OffsetTime
the actual value to verify
actual
,
Class<?>
the "self type"
selfType
)

Creates a new org.assertj.core.api.AbstractOffsetTimeAssert.

Method Summary

Modifier and TypeMethod and Description
private static boolean

Returns:

true if both OffsetTime are in the same year, month and day of month, hour, minute and second, false otherwise.
areEqualIgnoringNanos
(OffsetTime
the actual OffsetTime. expected not be null
actual
,
OffsetTime
the other OffsetTime. expected not be null
other
)

Returns true if both OffsetTime are in the same hour, minute and second, false otherwise.

private static boolean

Returns:

true if both OffsetTime are in the same hour and minute, false otherwise.
areEqualIgnoringSeconds
(OffsetTime
the actual OffsetTime. expected not be null
actual
,
OffsetTime
the other OffsetTime. expected not be null
other
)

Returns true if both OffsetTime are in the same hour and minute, false otherwise.

private static boolean

Returns:

true if both OffsetTime are in the same hour, minute, second and nanosecond false otherwise.
areEqualIgnoringTimezone
(OffsetTime
the actual OffsetTime. expected not be null
actual
,
OffsetTime
the other OffsetTime. expected not be null
other
)

Returns true if both OffsetTime are in the same hour, minute, second and nanosecond false otherwise.

private static void
assertOffsetTimeAsStringParameterIsNotNull(String
String representing the java.time.OffsetTime to compare actual with
OffsetTimeAsString
)

Check that the java.time.OffsetTime string representation to compare actual java.time.OffsetTime to is not null, otherwise throws a IllegalArgumentException with an explicit message

private static void
assertOffsetTimeParameterIsNotNull(OffsetTime other)

Check that the java.time.OffsetTime to compare actual java.time.OffsetTime to is not null, in that case throws a IllegalArgumentException with an explicit message

private void
private static Object[]
convertToOffsetTimeArray(String... offsetTimesAsString)

public SELF

Returns:

this assertion object.
hasSameHourAs
(OffsetTime other)

Verifies that actual and given OffsetTime have same hour fields (minute, second and nanosecond fields are ignored in comparison).

private static boolean
private static boolean
private static boolean
private static boolean
public SELF

Returns:

this assertion object.
isAfter
(OffsetTime other)

Verifies that the actual OffsetTime is strictly after the given one.

public SELF

Returns:

this assertion object.
isAfter
(String
String representing a java.time.OffsetTime.
offsetTimeAsString
)

Same assertion as isAfter(java.time.OffsetTime) but the java.time.OffsetTime is built from given a String that must follow ISO OffsetTime format to allow calling java.time.OffsetTime#parse(CharSequence) method.

public SELF

Returns:

this assertion object.
isAfterOrEqualTo
(OffsetTime other)

Verifies that the actual OffsetTime is after or equals to the given one.

public SELF

Returns:

this assertion object.
isAfterOrEqualTo
(String
String representing a java.time.OffsetTime.
offsetTimeAsString
)

Same assertion as isAfterOrEqualTo(java.time.OffsetTime) but the java.time.OffsetTime is built from given String, which must follow ISO OffsetTime format to allow calling java.time.OffsetTime#parse(CharSequence) method.

public SELF

Returns:

this assertion object.
isBefore
(OffsetTime other)

Verifies that the actual OffsetTime is strictly before the given one.

public SELF

Returns:

this assertion object.
isBefore
(String
String representing a java.time.OffsetTime.
offsetTimeAsString
)

Same assertion as isBefore(java.time.OffsetTime) but the java.time.OffsetTime is built from given String, which must follow ISO OffsetTime format to allow calling java.time.OffsetTime#parse(CharSequence) method.

public SELF

Returns:

this assertion object.
isBeforeOrEqualTo
(OffsetTime other)

Verifies that the actual OffsetTime is before or equals to the given one.

public SELF

Returns:

this assertion object.
isBeforeOrEqualTo
(String
String representing a java.time.OffsetTime.
offsetTimeAsString
)

Same assertion as isBeforeOrEqualTo(java.time.OffsetTime) but the java.time.OffsetTime is built from given String, which must follow ISO OffsetTime format to allow calling java.time.OffsetTime#parse(CharSequence) method.

public SELF

Returns:

this assertion object.
isBetween
(OffsetTime
the start value (inclusive), expected not to be null.
startInclusive
,
OffsetTime
the end value (inclusive), expected not to be null.
endInclusive
)

Verifies that the actual OffsetTime is in the [start, end] period (start and end included).

public SELF

Returns:

this assertion object.
isBetween
(String
the start value (inclusive), expected not to be null.
startInclusive
,
String
the end value (inclusive), expected not to be null.
endInclusive
)

Same assertion as isBetween(OffsetTime, OffsetTime) but here you pass OffsetTime String representations which must follow ISO OffsetTime format to allow calling OffsetTime#parse(CharSequence) method.

public SELF

Returns:

this assertion object
isCloseTo
(OffsetTime
the offsetTime to compare actual to
other
,
TemporalOffset<? super OffsetTime>
the offset used for comparison
offset
)

Overrides org.assertj.core.api.AbstractTemporalAssert.isCloseTo.

Verifies that the actual OffsetTime is close to the other according to the given TemporalOffset.
public SELF

Returns:

this assertion object.
isEqualTo
(String
String representing a java.time.OffsetTime.
offsetTimeAsString
)

Same assertion as isEqualTo(Object) (where Object is expected to be java.time.OffsetTime) but here you pass java.time.OffsetTime String representation that must follow ISO OffsetTime format to allow calling java.time.OffsetTime#parse(CharSequence) method.

public SELF

Returns:

this assertion object.
isEqualToIgnoringNanos
(OffsetTime other)

Deprecated Use isCloseTo(OffsetTime, TemporalOffset) instead, although not exactly the same semantics, this is the right way to compare with a given precision.
Verifies that actual and given OffsetTime have same hour, minute and second fields (nanosecond fields are ignored in comparison).
public SELF

Returns:

this assertion object.
isEqualToIgnoringSeconds
(OffsetTime other)

Deprecated Use isCloseTo(OffsetTime, TemporalOffset) instead, although not exactly the same semantics, this is the right way to compare with a given precision.
Verifies that actual and given java.time.OffsetTime have same hour and minute fields (second and nanosecond fields are ignored in comparison).
public SELF

Returns:

this assertion object.
isEqualToIgnoringTimezone
(OffsetTime other)

Verifies that actual and given java.time.OffsetTime have same hour, minute, second and nanosecond fields).

public SELF

Returns:

this assertion object.
isIn
(String...
String array representing java.time.OffsetTimes.
offsetTimesAsString
)

Same assertion as isIn(Object...) (where Objects are expected to be java.time.OffsetTime) but here you pass java.time.OffsetTime String representations that must follow ISO OffsetTime format to allow calling java.time.OffsetTime#parse(CharSequence) method.

public SELF

Returns:

this assertion object.
isNotEqualTo
(String
String representing a java.time.OffsetTime.
offsetTimeAsString
)

Same assertion as isNotEqualTo(Object) (where Object is expected to be java.time.OffsetTime) but here you pass java.time.OffsetTime String representation that must follow ISO OffsetTime format to allow calling java.time.OffsetTime#parse(CharSequence) method.

public SELF

Returns:

this assertion object.
isNotIn
(String...
Array of String representing a java.time.OffsetTime.
offsetTimesAsString
)

Same assertion as isNotIn(Object...) (where Objects are expected to be java.time.OffsetTime) but here you pass java.time.OffsetTime String representations that must follow ISO OffsetTime format to allow calling java.time.OffsetTime#parse(CharSequence) method.

public SELF

Returns:

this assertion object.
isStrictlyBetween
(OffsetTime
the start value (exclusive), expected not to be null.
startExclusive
,
OffsetTime
the end value (exclusive), expected not to be null.
endExclusive
)

Verifies that the actual OffsetTime is in the ]start, end[ period (start and end excluded).

public SELF

Returns:

this assertion object.
isStrictlyBetween
(String
the start value (exclusive), expected not to be null.
startExclusive
,
String
the end value (exclusive), expected not to be null.
endExclusive
)

Same assertion as isStrictlyBetween(OffsetTime, OffsetTime) but here you pass OffsetTime String representations which must follow ISO OffsetTime format to allow calling OffsetTime#parse(CharSequence) method.

protected OffsetTime
parse(String
the string to parse, not null
offsetTimeAsString
)

Implements abstract org.assertj.core.api.AbstractTemporalAssert.parse.

Obtains an instance of TEMPORAL from a string representation in ISO date format.
Inherited from org.assertj.core.api.AbstractTemporalAssert:
getActualisCloseTousingComparatorusingComparatorusingDefaultComparator

Field Detail

NULL_OFFSET_TIME_PARAMETER_MESSAGEback to summary
public static final String NULL_OFFSET_TIME_PARAMETER_MESSAGE

Constructor Detail

AbstractOffsetTimeAssertback to summary
protected AbstractOffsetTimeAssert(OffsetTime actual, Class<?> selfType)

Creates a new org.assertj.core.api.AbstractOffsetTimeAssert.

Parameters
actual:OffsetTime

the actual value to verify

selfType:Class<?>

the "self type"

Method Detail

areEqualIgnoringNanosback to summary
private static boolean areEqualIgnoringNanos(OffsetTime actual, OffsetTime other)

Returns true if both OffsetTime are in the same hour, minute and second, false otherwise.

Parameters
actual:OffsetTime

the actual OffsetTime. expected not be null

other:OffsetTime

the other OffsetTime. expected not be null

Returns:boolean

true if both OffsetTime are in the same year, month and day of month, hour, minute and second, false otherwise.

areEqualIgnoringSecondsback to summary
private static boolean areEqualIgnoringSeconds(OffsetTime actual, OffsetTime other)

Returns true if both OffsetTime are in the same hour and minute, false otherwise.

Parameters
actual:OffsetTime

the actual OffsetTime. expected not be null

other:OffsetTime

the other OffsetTime. expected not be null

Returns:boolean

true if both OffsetTime are in the same hour and minute, false otherwise.

areEqualIgnoringTimezoneback to summary
private static boolean areEqualIgnoringTimezone(OffsetTime actual, OffsetTime other)

Returns true if both OffsetTime are in the same hour, minute, second and nanosecond false otherwise.

Parameters
actual:OffsetTime

the actual OffsetTime. expected not be null

other:OffsetTime

the other OffsetTime. expected not be null

Returns:boolean

true if both OffsetTime are in the same hour, minute, second and nanosecond false otherwise.

assertOffsetTimeAsStringParameterIsNotNullback to summary
private static void assertOffsetTimeAsStringParameterIsNotNull(String OffsetTimeAsString)

Check that the java.time.OffsetTime string representation to compare actual java.time.OffsetTime to is not null, otherwise throws a IllegalArgumentException with an explicit message

Parameters
OffsetTimeAsString:String

String representing the java.time.OffsetTime to compare actual with

Exceptions
IllegalArgumentException:
with an explicit message if the given String is null
assertOffsetTimeParameterIsNotNullback to summary
private static void assertOffsetTimeParameterIsNotNull(OffsetTime other)

Check that the java.time.OffsetTime to compare actual java.time.OffsetTime to is not null, in that case throws a IllegalArgumentException with an explicit message

Parameters
other:OffsetTime

the java.time.OffsetTime to check

Exceptions
IllegalArgumentException:
with an explicit message if the given java.time.OffsetTime is null
checkIsNotNullAndNotEmptyback to summary
private void checkIsNotNullAndNotEmpty(Object[] values)
convertToOffsetTimeArrayback to summary
private static Object[] convertToOffsetTimeArray(String... offsetTimesAsString)
hasSameHourAsback to summary
public SELF hasSameHourAs(OffsetTime other)

Verifies that actual and given OffsetTime have same hour fields (minute, second and nanosecond fields are ignored in comparison).

Assertion can fail with OffsetTimes in same chronological second time window, e.g :

01:00:00.000+01:00 and 00:59:59.000+01:00.

Time difference is only 1s but hour fields differ.

Code example :

 // successful assertions
OffsetTime OffsetTime1 = OffsetTime.of(23, 50, 0, 0, ZoneOffset.UTC);
OffsetTime OffsetTime2 = OffsetTime.of(23, 00, 2, 7, ZoneOffset.UTC);
assertThat(OffsetTime1).hasSameHourAs(OffsetTime2);

// failing assertions (even if time difference is only 1ms)
OffsetTime OffsetTimeA = OffsetTime.of(01, 00, 00, 000, ZoneOffset.UTC);
OffsetTime OffsetTimeB = OffsetTime.of(00, 59, 59, 999, ZoneOffset.UTC);
assertThat(OffsetTimeA).hasSameHourAs(OffsetTimeB); 
Parameters
other:OffsetTime

the given java.time.OffsetTime.

Returns:SELF

this assertion object.

Exceptions
AssertionError:
  • if the actual OffsetTime is null.
  • if the actual OffsetTime is not equal ignoring minute, second and nanosecond fields.
IllegalArgumentException:
if other OffsetTime is null.
haveSameHourFieldback to summary
private static boolean haveSameHourField(OffsetTime actual, OffsetTime other)
haveSameMinuteback to summary
private static boolean haveSameMinute(OffsetTime actual, OffsetTime other)
haveSameNanoback to summary
private static boolean haveSameNano(OffsetTime actual, OffsetTime other)
haveSameSecondback to summary
private static boolean haveSameSecond(OffsetTime actual, OffsetTime other)
isAfterback to summary
public SELF isAfter(OffsetTime other)

Verifies that the actual OffsetTime is strictly after the given one.

Example :

 assertThat(parse("13:00:00Z")).isAfter(parse("12:00:00Z"));
Parameters
other:OffsetTime

the given java.time.OffsetTime.

Returns:SELF

this assertion object.

Exceptions
AssertionError:
  • if the actual OffsetTime is null.
  • if the actual OffsetTime is not strictly after the given one.
IllegalArgumentException:
if other OffsetTime is null.
isAfterback to summary
public SELF isAfter(String offsetTimeAsString)

Same assertion as isAfter(java.time.OffsetTime) but the java.time.OffsetTime is built from given a String that must follow ISO OffsetTime format to allow calling java.time.OffsetTime#parse(CharSequence) method.

Example :

 // you can express expected OffsetTime as String (AssertJ taking care of the conversion)
assertThat(parse("13:00:00Z")).isAfter("12:00:00Z");
Parameters
offsetTimeAsString:String

String representing a java.time.OffsetTime.

Returns:SELF

this assertion object.

Exceptions
AssertionError:
  • if the actual OffsetTime is null.
  • if the actual OffsetTime is not strictly after the java.time.OffsetTime built from given String.
IllegalArgumentException:
if given String is null or can't be converted to a java.time.OffsetTime.
isAfterOrEqualToback to summary
public SELF isAfterOrEqualTo(OffsetTime other)

Verifies that the actual OffsetTime is after or equals to the given one.

Example :

 assertThat(parse("13:00:00Z")).isAfterOrEqualTo(parse("13:00:00Z"))
                              .isAfterOrEqualTo(parse("12:00:00Z"));
Parameters
other:OffsetTime

the given java.time.OffsetTime.

Returns:SELF

this assertion object.

Exceptions
AssertionError:
  • if the actual OffsetTime is null.
  • if the actual OffsetTime is not after or equals to the given one.
IllegalArgumentException:
if other OffsetTime is null.
isAfterOrEqualToback to summary
public SELF isAfterOrEqualTo(String offsetTimeAsString)

Same assertion as isAfterOrEqualTo(java.time.OffsetTime) but the java.time.OffsetTime is built from given String, which must follow ISO OffsetTime format to allow calling java.time.OffsetTime#parse(CharSequence) method.

Example :

 // you can express expected OffsetTime as String (AssertJ taking care of the conversion)
assertThat(parse("13:00:00Z")).isAfterOrEqualTo("13:00:00Z")
                              .isAfterOrEqualTo("12:00:00Z");
Parameters
offsetTimeAsString:String

String representing a java.time.OffsetTime.

Returns:SELF

this assertion object.

Exceptions
AssertionError:
  • if the actual OffsetTime is null.
  • if the actual OffsetTime is not after or equals to the java.time.OffsetTime built from given String.
IllegalArgumentException:
if given String is null or can't be converted to a java.time.OffsetTime.
isBeforeback to summary
public SELF isBefore(OffsetTime other)

Verifies that the actual OffsetTime is strictly before the given one.

Example :

 assertThat(parse("12:00:00Z")).isBefore(parse("13:00:00Z"));
Parameters
other:OffsetTime

the given java.time.OffsetTime.

Returns:SELF

this assertion object.

Exceptions
AssertionError:
  • if the actual OffsetTime is null.
  • if the actual OffsetTime is not strictly before the given one.
IllegalArgumentException:
if other OffsetTime is null.
isBeforeback to summary
public SELF isBefore(String offsetTimeAsString)

Same assertion as isBefore(java.time.OffsetTime) but the java.time.OffsetTime is built from given String, which must follow ISO OffsetTime format to allow calling java.time.OffsetTime#parse(CharSequence) method.

Example :

 // you can express expected OffsetTime as String (AssertJ taking care of the conversion)
assertThat(parse("12:59Z")).isBefore("13:00Z");
Parameters
offsetTimeAsString:String

String representing a java.time.OffsetTime.

Returns:SELF

this assertion object.

Exceptions
AssertionError:
  • if the actual OffsetTime is null.
  • if the actual OffsetTime is not strictly before the java.time.OffsetTime built from given String.
IllegalArgumentException:
if given String is null or can't be converted to a java.time.OffsetTime.
isBeforeOrEqualToback to summary
public SELF isBeforeOrEqualTo(OffsetTime other)

Verifies that the actual OffsetTime is before or equals to the given one.

Example :

 assertThat(parse("12:00:00Z")).isBeforeOrEqualTo(parse("12:00:00Z"))
                              .isBeforeOrEqualTo(parse("12:00:01Z"));
Parameters
other:OffsetTime

the given java.time.OffsetTime.

Returns:SELF

this assertion object.

Exceptions
AssertionError:
  • if the actual OffsetTime is null.
  • if the actual OffsetTime is not before or equals to the given one.
IllegalArgumentException:
if other OffsetTime is null.
isBeforeOrEqualToback to summary
public SELF isBeforeOrEqualTo(String offsetTimeAsString)

Same assertion as isBeforeOrEqualTo(java.time.OffsetTime) but the java.time.OffsetTime is built from given String, which must follow ISO OffsetTime format to allow calling java.time.OffsetTime#parse(CharSequence) method.

Example :

 // you can express expected OffsetTime as String (AssertJ taking care of the conversion)
assertThat(parse("12:00:00Z")).isBeforeOrEqualTo("12:00:00Z")
                              .isBeforeOrEqualTo("13:00:00Z");
Parameters
offsetTimeAsString:String

String representing a java.time.OffsetTime.

Returns:SELF

this assertion object.

Exceptions
AssertionError:
  • if the actual OffsetTime is null.
  • if the actual OffsetTime is not before or equals to the java.time.OffsetTime built from given String.
IllegalArgumentException:
if given String is null or can't be converted to a java.time.OffsetTime.
isBetweenback to summary
public SELF isBetween(OffsetTime startInclusive, OffsetTime endInclusive)

Verifies that the actual OffsetTime is in the [start, end] period (start and end included).

Example:

 OffsetTime offsetTime = OffsetTime.now();

// assertions succeed:
assertThat(offsetTime).isBetween(offsetTime.minusSeconds(1), offsetTime.plusSeconds(1))
                      .isBetween(offsetTime, offsetTime.plusSeconds(1))
                      .isBetween(offsetTime.minusSeconds(1), offsetTime)
                      .isBetween(offsetTime, offsetTime);

// assertions fail:
assertThat(offsetTime).isBetween(offsetTime.minusSeconds(10), offsetTime.minusSeconds(1));
assertThat(offsetTime).isBetween(offsetTime.plusSeconds(1), offsetTime.plusSeconds(10));
Parameters
startInclusive:OffsetTime

the start value (inclusive), expected not to be null.

endInclusive:OffsetTime

the end value (inclusive), expected not to be null.

Returns:SELF

this assertion object.

Exceptions
AssertionError:
  • if the actual value is null.
  • if the actual value is not in [start, end] period.
NullPointerException:
  • if start value is null.
  • if end value is null.
Since
3.7.1
isBetweenback to summary
public SELF isBetween(String startInclusive, String endInclusive)

Same assertion as isBetween(OffsetTime, OffsetTime) but here you pass OffsetTime String representations which must follow ISO OffsetTime format to allow calling OffsetTime#parse(CharSequence) method.

Example:

 OffsetTime oneAm = OffsetTime.parse("01:00:00+02:00");

// assertions succeed:
assertThat(oneAm).isBetween("00:59:59+02:00", "01:00:01+02:00")
                 .isBetween("01:00:00+02:00", "01:00:01+02:00")
                 .isBetween("00:59:59+02:00", "01:00:00+02:00")
                 .isBetween("01:00:00+02:00", "01:00:00+02:00")

// assertion fails:
assertThat(oneAm).isBetween("01:00:01+02:00", "02:00:01+02:00");
Parameters
startInclusive:String

the start value (inclusive), expected not to be null.

endInclusive:String

the end value (inclusive), expected not to be null.

Returns:SELF

this assertion object.

Exceptions
AssertionError:
  • if the actual value is null.
  • if the actual value is not in [start, end] period.
NullPointerException:
  • if start value is null.
  • if end value is null.
DateTimeParseException:
if any of the given String can't be converted to a OffsetTime.
Since
3.7.1
isCloseToback to summary
public SELF isCloseTo(OffsetTime other, TemporalOffset<? super OffsetTime> offset)

Overrides org.assertj.core.api.AbstractTemporalAssert.isCloseTo.

Verifies that the actual OffsetTime is close to the other according to the given TemporalOffset.

You can build the offset parameter using Assertions#within(long, TemporalUnit) or Assertions#byLessThan(long, TemporalUnit).

Example:

 OffsetTime oneAm = OffsetTime.parse("01:00:00+02:00");

// assertion succeeds:
assertThat(oneAm).isCloseTo(oneAm.plusHours(1), within(30, ChronoUnit.MINUTES));

// assertion fails:
assertThat(oneAm).isCloseTo(_07_42, within(10, ChronoUnit.SECONDS));
Parameters
other:OffsetTime

the offsetTime to compare actual to

offset:TemporalOffset<? super OffsetTime>

the offset used for comparison

Returns:SELF

this assertion object

Annotations
@Override
Exceptions
NullPointerException:
if OffsetTime or TemporalOffset parameter is null.
AssertionError:
  • if the actual OffsetTime is null.
  • if the actual OffsetTime is not close to the given one within the provided offset.
isEqualToback to summary
public SELF isEqualTo(String offsetTimeAsString)

Same assertion as isEqualTo(Object) (where Object is expected to be java.time.OffsetTime) but here you pass java.time.OffsetTime String representation that must follow ISO OffsetTime format to allow calling java.time.OffsetTime#parse(CharSequence) method.

Example :

 // you can express expected OffsetTime as String (AssertJ taking care of the conversion)
assertThat(parse("13:00:00Z")).isEqualTo("13:00:00Z");
Parameters
offsetTimeAsString:String

String representing a java.time.OffsetTime.

Returns:SELF

this assertion object.

Exceptions
AssertionError:
  • if the actual OffsetTime is null.
  • if the actual OffsetTime is not equal to the java.time.OffsetTime built from given String.
IllegalArgumentException:
if given String is null or can't be converted to a java.time.OffsetTime.
isEqualToIgnoringNanosback to summary
public SELF isEqualToIgnoringNanos(OffsetTime other)

Deprecated

Use isCloseTo(OffsetTime, TemporalOffset) instead, although not exactly the same semantics, this is the right way to compare with a given precision.

Verifies that actual and given OffsetTime have same hour, minute and second fields (nanosecond fields are ignored in comparison).

Assertion can fail with OffsetTimes in same chronological nanosecond time window, e.g :

23:00:01.000000000+01:00 and 23:00:00.999999999+01:00.

Assertion fails as second fields differ even if time difference is only 1ns.

Code example :

 // successful assertions
OffsetTime OffsetTime1 = OffsetTime.of(12, 0, 1, 0, ZoneOffset.UTC);
OffsetTime OffsetTime2 = OffsetTime.of(12, 0, 1, 456, ZoneOffset.UTC);
assertThat(OffsetTime1).isEqualToIgnoringNanos(OffsetTime2);

// failing assertions (even if time difference is only 1ns)
OffsetTime OffsetTimeA = OffsetTime.of(12, 0, 1, 0, ZoneOffset.UTC);
OffsetTime OffsetTimeB = OffsetTime.of(12, 0, 0, 999999999, ZoneOffset.UTC);
assertThat(OffsetTimeA).isEqualToIgnoringNanos(OffsetTimeB);
Parameters
other:OffsetTime

the given java.time.OffsetTime.

Returns:SELF

this assertion object.

Annotations
@Deprecated
Exceptions
AssertionError:
  • if the actual OffsetTime is null.
  • if the actual OffsetTime is not equal with nanoseconds ignored.
IllegalArgumentException:
if other OffsetTime is null.
isEqualToIgnoringSecondsback to summary
public SELF isEqualToIgnoringSeconds(OffsetTime other)

Deprecated

Use isCloseTo(OffsetTime, TemporalOffset) instead, although not exactly the same semantics, this is the right way to compare with a given precision.

Verifies that actual and given java.time.OffsetTime have same hour and minute fields (second and nanosecond fields are ignored in comparison).

Assertion can fail with OffsetTimes in same chronological second time window, e.g :

23:01:00.000+01:00 and 23:00:59.000+01:00.

Assertion fails as minute fields differ even if time difference is only 1s.

Code example :

 // successful assertions
OffsetTime OffsetTime1 = OffsetTime.of(23, 50, 0, 0, ZoneOffset.UTC);
OffsetTime OffsetTime2 = OffsetTime.of(23, 50, 10, 456, ZoneOffset.UTC);
assertThat(OffsetTime1).isEqualToIgnoringSeconds(OffsetTime2);

// failing assertions (even if time difference is only 1ms)
OffsetTime OffsetTimeA = OffsetTime.of(23, 50, 00, 000, ZoneOffset.UTC);
OffsetTime OffsetTimeB = OffsetTime.of(23, 49, 59, 999, ZoneOffset.UTC);
assertThat(OffsetTimeA).isEqualToIgnoringSeconds(OffsetTimeB);
Parameters
other:OffsetTime

the given java.time.OffsetTime.

Returns:SELF

this assertion object.

Annotations
@Deprecated
Exceptions
AssertionError:
  • if the actual OffsetTime is null.
  • if the actual OffsetTime is not equal with second and nanosecond fields ignored.
IllegalArgumentException:
if other OffsetTime is null.
isEqualToIgnoringTimezoneback to summary
public SELF isEqualToIgnoringTimezone(OffsetTime other)

Verifies that actual and given java.time.OffsetTime have same hour, minute, second and nanosecond fields).

Code examples :

 // successful assertions
OffsetTime offsetTime = OffsetTime.of(12, 0, 0, 0, ZoneOffset.UTC);
OffsetTime offsetTime2 = OffsetTime.of(12, 0, 0, 0, ZoneOffset.MAX);
assertThat(offsetTime).isEqualToIgnoringTimezone(offsetTime2);

// failing assertions (even if time difference is only 1ms)
OffsetTime offsetTime = OffsetTime.of(12, 0, 0, 0, ZoneOffset.UTC);
OffsetTime offsetTime2 = OffsetTime.of(12, 1, 0, 0, ZoneOffset.UTC);
assertThat(offsetTime).isEqualToIgnoringTimezone(offsetTime2); 
Parameters
other:OffsetTime

the given java.time.OffsetTime.

Returns:SELF

this assertion object.

Exceptions
AssertionError:
  • if the actual OffsetTime is null.
  • if the actual OffsetTime is not equal with timezone ignored.
IllegalArgumentException:
if other OffsetTime is null.
isInback to summary
public SELF isIn(String... offsetTimesAsString)

Same assertion as isIn(Object...) (where Objects are expected to be java.time.OffsetTime) but here you pass java.time.OffsetTime String representations that must follow ISO OffsetTime format to allow calling java.time.OffsetTime#parse(CharSequence) method.

Example :

 // you can express expected OffsetTimes as String (AssertJ taking care of the conversion)
assertThat(parse("13:00:00Z")).isIn("12:00:00Z", "13:00:00Z");
Parameters
offsetTimesAsString:String[]

String array representing java.time.OffsetTimes.

Returns:SELF

this assertion object.

Exceptions
AssertionError:
  • if the actual OffsetTime is null.
  • if the actual OffsetTime is not in the java.time.OffsetTimes built from given Strings.
IllegalArgumentException:
if given String is null or can't be converted to a java.time.OffsetTime.
isNotEqualToback to summary
public SELF isNotEqualTo(String offsetTimeAsString)

Same assertion as isNotEqualTo(Object) (where Object is expected to be java.time.OffsetTime) but here you pass java.time.OffsetTime String representation that must follow ISO OffsetTime format to allow calling java.time.OffsetTime#parse(CharSequence) method.

Example :

 // you can express expected OffsetTime as String (AssertJ taking care of the conversion)
assertThat(parse("13:00:00Z")).isNotEqualTo("12:00:00Z");
Parameters
offsetTimeAsString:String

String representing a java.time.OffsetTime.

Returns:SELF

this assertion object.

Exceptions
AssertionError:
  • if the actual OffsetTime is null.
  • if the actual OffsetTime is equal to the java.time.OffsetTime built from given String.
IllegalArgumentException:
if given String is null or can't be converted to a java.time.OffsetTime.
isNotInback to summary
public SELF isNotIn(String... offsetTimesAsString)

Same assertion as isNotIn(Object...) (where Objects are expected to be java.time.OffsetTime) but here you pass java.time.OffsetTime String representations that must follow ISO OffsetTime format to allow calling java.time.OffsetTime#parse(CharSequence) method.

Example :

 // you can express expected OffsetTimes as String (AssertJ taking care of the conversion)
assertThat(parse("13:00:00Z")).isNotIn("12:00:00Z", "14:00:00Z");
Parameters
offsetTimesAsString:String[]

Array of String representing a java.time.OffsetTime.

Returns:SELF

this assertion object.

Exceptions
AssertionError:
  • if the actual OffsetTime is null.
  • if the actual OffsetTime is in the java.time.OffsetTimes built from given Strings.
IllegalArgumentException:
if given String is null or can't be converted to a java.time.OffsetTime.
isStrictlyBetweenback to summary
public SELF isStrictlyBetween(OffsetTime startExclusive, OffsetTime endExclusive)

Verifies that the actual OffsetTime is in the ]start, end[ period (start and end excluded).

Example:

 OffsetTime offsetTime = OffsetTime.now();

// assertion succeeds:
assertThat(offsetTime).isStrictlyBetween(offsetTime.minusSeconds(1), offsetTime.plusSeconds(1));

// assertions fail:
assertThat(offsetTime).isStrictlyBetween(offsetTime.minusSeconds(10), offsetTime.minusSeconds(1));
assertThat(offsetTime).isStrictlyBetween(offsetTime.plusSeconds(1), offsetTime.plusSeconds(10));
assertThat(offsetTime).isStrictlyBetween(offsetTime, offsetTime.plusSeconds(1));
assertThat(offsetTime).isStrictlyBetween(offsetTime.minusSeconds(1), offsetTime);
Parameters
startExclusive:OffsetTime

the start value (exclusive), expected not to be null.

endExclusive:OffsetTime

the end value (exclusive), expected not to be null.

Returns:SELF

this assertion object.

Exceptions
AssertionError:
  • if the actual value is null.
  • if the actual value is not in ]start, end[ period.
NullPointerException:
  • if start value is null.
  • if end value is null.
Since
3.7.1
isStrictlyBetweenback to summary
public SELF isStrictlyBetween(String startExclusive, String endExclusive)

Same assertion as isStrictlyBetween(OffsetTime, OffsetTime) but here you pass OffsetTime String representations which must follow ISO OffsetTime format to allow calling OffsetTime#parse(CharSequence) method.

Example:

 OffsetTime oneAm = OffsetTime.parse("01:00:00+02:00");

// assertion succeeds:
assertThat(oneAm).isStrictlyBetween("00:59:59+02:00", "01:00:01+02:00");

// assertions fail:
assertThat(oneAm).isStrictlyBetween("02:00:00+02:00", "03:00:00+02:00");
assertThat(oneAm).isStrictlyBetween("00:59:59+02:00", "01:00:00+02:00");
assertThat(oneAm).isStrictlyBetween("01:00:00+02:00", "01:00:01+02:00");
Parameters
startExclusive:String

the start value (exclusive), expected not to be null.

endExclusive:String

the end value (exclusive), expected not to be null.

Returns:SELF

this assertion object.

Exceptions
AssertionError:
  • if the actual value is null.
  • if the actual value is not in ]start, end[ period.
NullPointerException:
  • if start value is null.
  • if end value is null.
DateTimeParseException:
if any of the given String can't be converted to a OffsetTime.
Since
3.7.1
parseback to summary
protected OffsetTime parse(String offsetTimeAsString)

Implements abstract org.assertj.core.api.AbstractTemporalAssert.parse.

Doc from org.assertj.core.api.AbstractTemporalAssert.parse.

Obtains an instance of TEMPORAL from a string representation in ISO date format.

Parameters
offsetTimeAsString:String

the string to parse, not null

Returns:OffsetTime

the parsed TEMPORAL, not null

Annotations
@Override