Class AbstractOffsetDateTimeAssert<SELF extends AbstractOffsetDateTimeAssert<SELF>>

  • Type Parameters:
    SELF - the "self" type of this assertion class.
    All Implemented Interfaces:
    Assert<SELF,​java.time.OffsetDateTime>, Descriptable<SELF>, ExtensionPoints<SELF,​java.time.OffsetDateTime>
    Direct Known Subclasses:
    OffsetDateTimeAssert

    public abstract class AbstractOffsetDateTimeAssert<SELF extends AbstractOffsetDateTimeAssert<SELF>>
    extends AbstractTemporalAssert<SELF,​java.time.OffsetDateTime>
    Assertions for OffsetDateTime type from new Date & Time API introduced in Java 8.
    • Field Detail

      • NULL_OFFSET_DATE_TIME_PARAMETER_MESSAGE

        public static final java.lang.String NULL_OFFSET_DATE_TIME_PARAMETER_MESSAGE
        See Also:
        Constant Field Values
    • Constructor Detail

      • AbstractOffsetDateTimeAssert

        protected AbstractOffsetDateTimeAssert​(java.time.OffsetDateTime actual,
                                               java.lang.Class<?> selfType)
        Parameters:
        selfType - the "self type"
        actual - the actual value to verify
    • Method Detail

      • isBefore

        public SELF isBefore​(java.time.OffsetDateTime other)
        Verifies that the actual OffsetDateTime is strictly before the given one.

        Example :

         assertThat(parse("2000-01-01T23:59:59Z")).isBefore(parse("2000-01-02T00:00:00Z"));
        Parameters:
        other - the given OffsetDateTime.
        Returns:
        this assertion object.
        Throws:
        java.lang.AssertionError - if the actual OffsetDateTime is null.
        java.lang.IllegalArgumentException - if other OffsetDateTime is null.
        java.lang.AssertionError - if the actual OffsetDateTime is not strictly before the given one.
      • isBefore

        public SELF isBefore​(java.lang.String offsetDateTimeAsString)
        Same assertion as isBefore(java.time.OffsetDateTime) but the OffsetDateTime is built from given String, which must follow ISO OffsetDateTime format to allow calling OffsetDateTime.parse(CharSequence) method.

        Example :

         // use String in comparison to avoid writing the code to perform the conversion
         assertThat(parse("2000-01-01T23:59:59Z")).isBefore("2000-01-02T00:00:00Z");
        Parameters:
        offsetDateTimeAsString - String representing a OffsetDateTime.
        Returns:
        this assertion object.
        Throws:
        java.lang.AssertionError - if the actual OffsetDateTime is null.
        java.lang.IllegalArgumentException - if given String is null or can't be converted to a OffsetDateTime.
        java.lang.AssertionError - if the actual OffsetDateTime is not strictly before the OffsetDateTime built from given String.
      • isBeforeOrEqualTo

        public SELF isBeforeOrEqualTo​(java.time.OffsetDateTime other)
        Verifies that the actual OffsetDateTime is before or equals to the given one.

        Example :

         assertThat(parse("2000-01-01T23:59:59Z")).isBeforeOrEqualTo(parse("2000-01-01T23:59:59Z"))
                                                  .isBeforeOrEqualTo(parse("2000-01-02T00:00:00Z"));
        Parameters:
        other - the given OffsetDateTime.
        Returns:
        this assertion object.
        Throws:
        java.lang.AssertionError - if the actual OffsetDateTime is null.
        java.lang.IllegalArgumentException - if other OffsetDateTime is null.
        java.lang.AssertionError - if the actual OffsetDateTime is not before or equals to the given one.
      • isBeforeOrEqualTo

        public SELF isBeforeOrEqualTo​(java.lang.String offsetDateTimeAsString)
        Same assertion as isBeforeOrEqualTo(java.time.OffsetDateTime) but the OffsetDateTime is built from given String, which must follow ISO OffsetDateTime format to allow calling OffsetDateTime.parse(CharSequence) method.

        Example :

         // use String in comparison to avoid conversion
         assertThat(parse("2000-01-01T23:59:59Z")).isBeforeOrEqualTo("2000-01-01T23:59:59Z")
                                                  .isBeforeOrEqualTo("2000-01-02T00:00:00Z");
        Parameters:
        offsetDateTimeAsString - String representing a OffsetDateTime.
        Returns:
        this assertion object.
        Throws:
        java.lang.AssertionError - if the actual OffsetDateTime is null.
        java.lang.IllegalArgumentException - if given String is null or can't be converted to a OffsetDateTime.
        java.lang.AssertionError - if the actual OffsetDateTime is not before or equals to the OffsetDateTime built from given String.
      • isAfterOrEqualTo

        public SELF isAfterOrEqualTo​(java.time.OffsetDateTime other)
        Verifies that the actual OffsetDateTime is after or equals to the given one.

        Example :

         assertThat(parse("2000-01-01T00:00:00Z")).isAfterOrEqualTo(parse("2000-01-01T00:00:00Z"))
                                                  .isAfterOrEqualTo(parse("1999-12-31T23:59:59Z"));
        Parameters:
        other - the given OffsetDateTime.
        Returns:
        this assertion object.
        Throws:
        java.lang.AssertionError - if the actual OffsetDateTime is null.
        java.lang.IllegalArgumentException - if other OffsetDateTime is null.
        java.lang.AssertionError - if the actual OffsetDateTime is not after or equals to the given one.
      • isAfterOrEqualTo

        public SELF isAfterOrEqualTo​(java.lang.String offsetDateTimeAsString)
        Same assertion as isAfterOrEqualTo(java.time.OffsetDateTime) but the OffsetDateTime is built from given String, which must follow ISO OffsetDateTime format to allow calling OffsetDateTime.parse(CharSequence) method.

        Example :

         // use String in comparison to avoid conversion
         assertThat(parse("2000-01-01T00:00:00Z")).isAfterOrEqualTo("2000-01-01T00:00:00Z")
                                                  .isAfterOrEqualTo("1999-12-31T23:59:59Z");
        Parameters:
        offsetDateTimeAsString - String representing a OffsetDateTime.
        Returns:
        this assertion object.
        Throws:
        java.lang.AssertionError - if the actual OffsetDateTime is null.
        java.lang.IllegalArgumentException - if given String is null or can't be converted to a OffsetDateTime.
        java.lang.AssertionError - if the actual OffsetDateTime is not after or equals to the OffsetDateTime built from given String.
      • isAfter

        public SELF isAfter​(java.time.OffsetDateTime other)
        Verifies that the actual OffsetDateTime is strictly after the given one.

        Example :

         assertThat(parse("2000-01-01T00:00:00Z")).isAfter(parse("1999-12-31T23:59:59Z"));
        Parameters:
        other - the given OffsetDateTime.
        Returns:
        this assertion object.
        Throws:
        java.lang.AssertionError - if the actual OffsetDateTime is null.
        java.lang.IllegalArgumentException - if other OffsetDateTime is null.
        java.lang.AssertionError - if the actual OffsetDateTime is not strictly after the given one.
      • isAfter

        public SELF isAfter​(java.lang.String offsetDateTimeAsString)
        Same assertion as isAfter(java.time.OffsetDateTime) but the OffsetDateTime is built from given a String that must follow ISO OffsetDateTime format to allow calling OffsetDateTime.parse(CharSequence) method.

        Example :

         // use String in comparison to avoid conversion
         assertThat(parse("2000-01-01T00:00:00Z")).isAfter("1999-12-31T23:59:59Z");
        Parameters:
        offsetDateTimeAsString - String representing a OffsetDateTime.
        Returns:
        this assertion object.
        Throws:
        java.lang.AssertionError - if the actual OffsetDateTime is null.
        java.lang.IllegalArgumentException - if given String is null or can't be converted to a OffsetDateTime.
        java.lang.AssertionError - if the actual OffsetDateTime is not strictly after the OffsetDateTime built from given String.
      • isCloseToUtcNow

        public SELF isCloseToUtcNow​(TemporalUnitOffset offset)
        Verifies that the actual OffsetDateTime is close to the current date and time on the UTC timezone, according to the given TemporalUnitOffset. You can build the offset parameter using Assertions.within(long, TemporalUnit) or Assertions.byLessThan(long, TemporalUnit).

        If the difference is equal to the offset, the assertion succeeds.

        Example:

         OffsetDateTime actual = OffsetDateTime.now(Clock.systemUTC());
        
         // assertion will pass as if executed less than one second after actual was built
         assertThat(actual).isCloseToUtcNow(within(1, ChronoUnit.SECONDS));
        
         // assertion will fail
         assertThat(actual.plusSeconds(2)).isCloseToUtcNow(within(1, ChronoUnit.SECONDS));
        Parameters:
        offset - The offset used for comparison
        Returns:
        this assertion object
        Throws:
        java.lang.NullPointerException - if offset parameter is null.
        java.lang.AssertionError - if the actual OffsetDateTime is null.
        java.lang.AssertionError - if the actual OffsetDateTime is not close to the current time by less than the given offset.
      • isEqualTo

        public SELF isEqualTo​(java.lang.String dateTimeAsString)
        Same assertion as AbstractAssert.isEqualTo(Object) (where Object is expected to be OffsetDateTime) but here you pass OffsetDateTime String representation that must follow ISO OffsetDateTime format to allow calling OffsetDateTime.parse(CharSequence) method.

        Example :

         // use String in comparison to avoid writing the code to perform the conversion
         assertThat(parse("2000-01-01T00:00:00Z")).isEqualTo("2000-01-01T00:00:00Z");
        Parameters:
        dateTimeAsString - String representing a OffsetDateTime.
        Returns:
        this assertion object.
        Throws:
        java.lang.AssertionError - if the actual OffsetDateTime is null.
        java.lang.IllegalArgumentException - if given String is null or can't be converted to a OffsetDateTime.
        java.lang.AssertionError - if the actual OffsetDateTime is not equal to the OffsetDateTime built from given String.
      • isNotEqualTo

        public SELF isNotEqualTo​(java.lang.String dateTimeAsString)
        Same assertion as AbstractAssert.isNotEqualTo(Object) (where Object is expected to be OffsetDateTime) but here you pass OffsetDateTime String representation that must follow ISO OffsetDateTime format to allow calling OffsetDateTime.parse(CharSequence) method.

        Example :

         // use String in comparison to avoid writing the code to perform the conversion
         assertThat(parse("2000-01-01T00:00:00Z")).isNotEqualTo("2000-01-15T00:00:00Z");
        Parameters:
        dateTimeAsString - String representing a OffsetDateTime.
        Returns:
        this assertion object.
        Throws:
        java.lang.AssertionError - if the actual OffsetDateTime is null.
        java.lang.IllegalArgumentException - if given String is null or can't be converted to a OffsetDateTime.
        java.lang.AssertionError - if the actual OffsetDateTime is equal to the OffsetDateTime built from given String.
      • isIn

        public SELF isIn​(java.lang.String... dateTimesAsString)
        Same assertion as AbstractAssert.isIn(Object...) (where Objects are expected to be OffsetDateTime) but here you pass OffsetDateTime String representations that must follow ISO OffsetDateTime format to allow calling OffsetDateTime.parse(CharSequence) method.

        Example :

         // use String based representation of OffsetDateTime
         assertThat(parse("2000-01-01T00:00:00Z")).isIn("1999-12-31T00:00:00Z", "2000-01-01T00:00:00Z");
        Parameters:
        dateTimesAsString - String array representing OffsetDateTimes.
        Returns:
        this assertion object.
        Throws:
        java.lang.AssertionError - if the actual OffsetDateTime is null.
        java.lang.IllegalArgumentException - if given String is null or can't be converted to a OffsetDateTime.
        java.lang.AssertionError - if the actual OffsetDateTime is not in the OffsetDateTimes built from given Strings.
      • isNotIn

        public SELF isNotIn​(java.lang.String... dateTimesAsString)
        Same assertion as AbstractAssert.isNotIn(Object...) (where Objects are expected to be OffsetDateTime) but here you pass OffsetDateTime String representations that must follow ISO OffsetDateTime format to allow calling OffsetDateTime.parse(CharSequence) method.

        Example :

         // use String based representation of OffsetDateTime
         assertThat(parse("2000-01-01T00:00:00Z")).isNotIn("1999-12-31T00:00:00Z", "2000-01-02T00:00:00Z");
        Parameters:
        dateTimesAsString - Array of String representing a OffsetDateTime.
        Returns:
        this assertion object.
        Throws:
        java.lang.AssertionError - if the actual OffsetDateTime is null.
        java.lang.IllegalArgumentException - if given String is null or can't be converted to a OffsetDateTime.
        java.lang.AssertionError - if the actual OffsetDateTime is in the OffsetDateTimes built from given Strings.
      • isEqualToIgnoringNanos

        public SELF isEqualToIgnoringNanos​(java.time.OffsetDateTime other)
        Verifies that actual and given OffsetDateTime have same year, month, day, hour, minute and second fields, (nanosecond fields are ignored in comparison).

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

        2000-01-01T00:00:01.000000000+01:00 and 2000-01-01T00:00:00.999999999+01:00.

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

        Code example :

         // successful assertions
         OffsetDateTime OffsetDateTime1 = OffsetDateTime.of(2000, 1, 1, 0, 0, 1, 0, ZoneOffset.UTC);
         OffsetDateTime OffsetDateTime2 = OffsetDateTime.of(2000, 1, 1, 0, 0, 1, 456, ZoneOffset.UTC);
         assertThat(OffsetDateTime1).isEqualToIgnoringNanos(OffsetDateTime2);
         // failing assertions (even if time difference is only 1ns)
         OffsetDateTime OffsetDateTimeA = OffsetDateTime.of(2000, 1, 1, 0, 0, 1, 0, ZoneOffset.UTC);
         OffsetDateTime OffsetDateTimeB = OffsetDateTime.of(2000, 1, 1, 0, 0, 0, 999999999, ZoneOffset.UTC);
         assertThat(OffsetDateTimeA).isEqualToIgnoringNanos(OffsetDateTimeB);
        Parameters:
        other - the given OffsetDateTime.
        Returns:
        this assertion object.
        Throws:
        java.lang.AssertionError - if the actual OffsetDateTime is null.
        java.lang.IllegalArgumentException - if other OffsetDateTime is null.
        java.lang.AssertionError - if the actual OffsetDateTime is are not equal with nanoseconds ignored.
      • isEqualToIgnoringTimezone

        public SELF isEqualToIgnoringTimezone​(java.time.OffsetDateTime other)
        Verifies that actual and given OffsetDateTime have same year, month, day, hour, minute, second and nanosecond fields, (timezone fields are ignored in comparison).

        Code example :

         // successful assertions
         OffsetDateTime OffsetDateTime1 = OffsetDateTime.of(2000, 1, 1, 0, 0, 1, 0, ZoneOffset.UTC);
         OffsetDateTime OffsetDateTime2 = OffsetDateTime.of(2000, 1, 1, 0, 0, 1, 0, ZoneOffset.MAX);
         assertThat(OffsetDateTime1).isEqualToIgnoringTimezone(OffsetDateTime2);
        
         // failing assertions
         OffsetDateTime OffsetDateTimeA = OffsetDateTime.of(2000, 1, 1, 0, 0, 1, 0, ZoneOffset.UTC);
         OffsetDateTime OffsetDateTimeB = OffsetDateTime.of(2000, 1, 1, 0, 0, 0, 999999999, ZoneOffset.UTC);
         assertThat(OffsetDateTimeA).isEqualToIgnoringTimezone(OffsetDateTimeB);
        Parameters:
        other - the given OffsetDateTime.
        Returns:
        this assertion object.
        Throws:
        java.lang.AssertionError - if the actual OffsetDateTime is null.
        java.lang.IllegalArgumentException - if other OffsetDateTime is null.
        java.lang.AssertionError - if the actual OffsetDateTime is are not equal with timezone ignored.
      • isEqualToIgnoringSeconds

        public SELF isEqualToIgnoringSeconds​(java.time.OffsetDateTime other)
        Verifies that actual and given OffsetDateTime have same year, month, day, hour and minute fields (second and nanosecond fields are ignored in comparison).

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

        2000-01-01T00:01:00.000+01:00 and 2000-01-01T00:00:59.000+01:00.

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

        Code example :

         // successful assertions
         OffsetDateTime OffsetDateTime1 = OffsetDateTime.of(2000, 1, 1, 23, 50, 0, 0, ZoneOffset.UTC);
         OffsetDateTime OffsetDateTime2 = OffsetDateTime.of(2000, 1, 1, 23, 50, 10, 456, ZoneOffset.UTC);
         assertThat(OffsetDateTime1).isEqualToIgnoringSeconds(OffsetDateTime2);
        
         // failing assertions (even if time difference is only 1ms)
         OffsetDateTime OffsetDateTimeA = OffsetDateTime.of(2000, 1, 1, 23, 50, 00, 000, ZoneOffset.UTC);
         OffsetDateTime OffsetDateTimeB = OffsetDateTime.of(2000, 1, 1, 23, 49, 59, 999, ZoneOffset.UTC);
         assertThat(OffsetDateTimeA).isEqualToIgnoringSeconds(OffsetDateTimeB);
        Parameters:
        other - the given OffsetDateTime.
        Returns:
        this assertion object.
        Throws:
        java.lang.AssertionError - if the actual OffsetDateTime is null.
        java.lang.IllegalArgumentException - if other OffsetDateTime is null.
        java.lang.AssertionError - if the actual OffsetDateTime is are not equal with second and nanosecond fields ignored.
      • isEqualToIgnoringMinutes

        public SELF isEqualToIgnoringMinutes​(java.time.OffsetDateTime other)
        Verifies that actual and given OffsetDateTime have same year, month, day and hour fields (minute, second and nanosecond fields are ignored in comparison).

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

        2000-01-01T01:00:00.000+01:00 and 2000-01-01T00:59:59.000+01:00.

        Time difference is only 1s but hour fields differ.

        Code example :

         // successful assertions
         OffsetDateTime OffsetDateTime1 = OffsetDateTime.of(2000, 1, 1, 23, 50, 0, 0, ZoneOffset.UTC);
         OffsetDateTime OffsetDateTime2 = OffsetDateTime.of(2000, 1, 1, 23, 00, 2, 7, ZoneOffset.UTC);
         assertThat(OffsetDateTime1).isEqualToIgnoringMinutes(OffsetDateTime2);
        
         // failing assertions (even if time difference is only 1ms)
         OffsetDateTime OffsetDateTimeA = OffsetDateTime.of(2000, 1, 1, 01, 00, 00, 000, ZoneOffset.UTC);
         OffsetDateTime OffsetDateTimeB = OffsetDateTime.of(2000, 1, 1, 00, 59, 59, 999, ZoneOffset.UTC);
         assertThat(OffsetDateTimeA).isEqualToIgnoringMinutes(OffsetDateTimeB);
        Parameters:
        other - the given OffsetDateTime.
        Returns:
        this assertion object.
        Throws:
        java.lang.AssertionError - if the actual OffsetDateTime is null.
        java.lang.IllegalArgumentException - if other OffsetDateTime is null.
        java.lang.AssertionError - if the actual OffsetDateTime is are not equal ignoring minute, second and nanosecond fields.
      • isEqualToIgnoringHours

        public SELF isEqualToIgnoringHours​(java.time.OffsetDateTime other)
        Verifies that actual and given OffsetDateTime have same year, month and day fields (hour, minute, second and nanosecond fields are ignored in comparison).

        Assertion can fail with OffsetDateTimes in same chronological minute time window, e.g :

        2000-01-01T23:59:00.000+01:00 and 2000-01-02T00:00:00.000+01:00.

        Time difference is only 1min but day fields differ.

        Code example :

         // successful assertions
         OffsetDateTime OffsetDateTime1 = OffsetDateTime.of(2000, 1, 1, 23, 59, 59, 999, ZoneOffset.UTC);
         OffsetDateTime OffsetDateTime2 = OffsetDateTime.of(2000, 1, 1, 00, 00, 00, 000, ZoneOffset.UTC);
         assertThat(OffsetDateTime1).isEqualToIgnoringHours(OffsetDateTime2);
        
         // failing assertions (even if time difference is only 1ms)
         OffsetDateTime OffsetDateTimeA = OffsetDateTime.of(2000, 1, 2, 00, 00, 00, 000, ZoneOffset.UTC);
         OffsetDateTime OffsetDateTimeB = OffsetDateTime.of(2000, 1, 1, 23, 59, 59, 999, ZoneOffset.UTC);
         assertThat(OffsetDateTimeA).isEqualToIgnoringHours(OffsetDateTimeB);
        Parameters:
        other - the given OffsetDateTime.
        Returns:
        this assertion object.
        Throws:
        java.lang.AssertionError - if the actual OffsetDateTime is null.
        java.lang.IllegalArgumentException - if other OffsetDateTime is null.
        java.lang.AssertionError - if the actual OffsetDateTime is are not equal with second and nanosecond fields ignored.
      • isBetween

        public SELF isBetween​(java.time.OffsetDateTime startExclusive,
                              java.time.OffsetDateTime endExclusive)
        Verifies that the actual OffsetDateTime is in the [start, end] period (start and end included).

        Example:

         OffsetDateTime offsetDateTime = OffsetDateTime.now();
        
         // assertions succeed:
         assertThat(offsetDateTime).isBetween(offsetDateTime.minusSeconds(1), offsetDateTime.plusSeconds(1))
                                   .isBetween(offsetDateTime, offsetDateTime.plusSeconds(1))
                                   .isBetween(offsetDateTime.minusSeconds(1), offsetDateTime)
                                   .isBetween(offsetDateTime, offsetDateTime);
        
         // assertions fail:
         assertThat(offsetDateTime).isBetween(offsetDateTime.minusSeconds(10), offsetDateTime.minusSeconds(1));
         assertThat(offsetDateTime).isBetween(offsetDateTime.plusSeconds(1), offsetDateTime.plusSeconds(10));
        Parameters:
        startExclusive - the start value (exclusive), expected not to be null.
        endExclusive - the end value (exclusive), expected not to be null.
        Returns:
        this assertion object.
        Throws:
        java.lang.AssertionError - if the actual value is null.
        java.lang.NullPointerException - if start value is null.
        java.lang.NullPointerException - if end value is null.
        java.lang.AssertionError - if the actual value is not in [start, end] period.
        Since:
        3.7.1
      • isBetween

        public SELF isBetween​(java.lang.String startExclusive,
                              java.lang.String endExclusive)
        Same assertion as isBetween(OffsetDateTime, OffsetDateTime) but here you pass OffsetDateTime String representations which must follow ISO OffsetDateTime format to allow calling OffsetDateTime.parse(CharSequence) method.

        Example:

         OffsetDateTime firstOfJanuary2000 = OffsetDateTime.parse("2000-01-01T00:00:00Z");
        
         // assertions succeed:
         assertThat(firstOfJanuary2000).isBetween("1999-12-31T23:59:59Z", "2000-01-01T00:00:01Z")
                                       .isBetween("2000-01-01T00:00:00Z", "2000-01-01T00:00:01Z")
                                       .isBetween("1999-12-31T23:59:59Z", "2000-01-01T00:00:00Z")
                                       .isBetween("2000-01-01T00:00:00Z", "2000-01-01T00:00:00Z");
        
         // assertion fails:
         assertThat(firstOfJanuary2000).isBetween("1999-01-01T00:00:01Z", "1999-12-31T23:59:59Z");
        Parameters:
        startExclusive - the start value (exclusive), expected not to be null.
        endExclusive - the end value (exclusive), expected not to be null.
        Returns:
        this assertion object.
        Throws:
        java.lang.AssertionError - if the actual value is null.
        java.lang.NullPointerException - if start value is null.
        java.lang.NullPointerException - if end value is null.
        java.time.format.DateTimeParseException - if any of the given String can't be converted to a OffsetDateTime.
        java.lang.AssertionError - if the actual value is not in [start, end] period.
        Since:
        3.7.1
      • isStrictlyBetween

        public SELF isStrictlyBetween​(java.time.OffsetDateTime startExclusive,
                                      java.time.OffsetDateTime endExclusive)
        Verifies that the actual OffsetDateTime is in the ]start, end[ period (start and end excluded).

        Example:

         OffsetDateTime offsetDateTime = OffsetDateTime.now();
        
         // assertion succeeds:
         assertThat(offsetDateTime).isStrictlyBetween(offsetDateTime.minusSeconds(1), offsetDateTime.plusSeconds(1));
        
         // assertions fail:
         assertThat(offsetDateTime).isStrictlyBetween(offsetDateTime.minusSeconds(10), offsetDateTime.minusSeconds(1));
         assertThat(offsetDateTime).isStrictlyBetween(offsetDateTime.plusSeconds(1), offsetDateTime.plusSeconds(10));
         assertThat(offsetDateTime).isStrictlyBetween(offsetDateTime, offsetDateTime.plusSeconds(1));
         assertThat(offsetDateTime).isStrictlyBetween(offsetDateTime.minusSeconds(1), offsetDateTime);
        Parameters:
        startExclusive - the start value (exclusive), expected not to be null.
        endExclusive - the end value (exclusive), expected not to be null.
        Returns:
        this assertion object.
        Throws:
        java.lang.AssertionError - if the actual value is null.
        java.lang.NullPointerException - if start value is null.
        java.lang.NullPointerException - if end value is null.
        java.lang.AssertionError - if the actual value is not in ]start, end[ period.
        Since:
        3.7.1
      • isStrictlyBetween

        public SELF isStrictlyBetween​(java.lang.String startExclusive,
                                      java.lang.String endExclusive)
        Same assertion as isStrictlyBetween(OffsetDateTime, OffsetDateTime) but here you pass OffsetDateTime String representations which must follow ISO OffsetDateTime format to allow calling OffsetDateTime.parse(CharSequence) method.

        Example:

         OffsetDateTime firstOfJanuary2000 = OffsetDateTime.parse("2000-01-01T00:00:00Z");
        
         // assertion succeeds:
         assertThat(firstOfJanuary2000).isStrictlyBetween("1999-12-31T23:59:59Z", "2000-01-01T00:00:01Z");
        
         // assertions fail:
         assertThat(firstOfJanuary2000).isStrictlyBetween("1999-01-01T00:00:01Z", "1999-12-31T23:59:59Z");
         assertThat(firstOfJanuary2000).isStrictlyBetween("2000-01-01T00:00:00Z", "2000-01-01T00:00:01Z");
         assertThat(firstOfJanuary2000).isStrictlyBetween("1999-12-31T23:59:59Z", "2000-01-01T00:00:00Z");
        Parameters:
        startExclusive - the start value (exclusive), expected not to be null.
        endExclusive - the end value (exclusive), expected not to be null.
        Returns:
        this assertion object.
        Throws:
        java.lang.AssertionError - if the actual value is null.
        java.lang.NullPointerException - if start value is null.
        java.lang.NullPointerException - if end value is null.
        java.time.format.DateTimeParseException - if any of the given String can't be converted to a OffsetDateTime.
        java.lang.AssertionError - if the actual value is not in ]start, end[ period.
        Since:
        3.7.1
      • parse

        protected java.time.OffsetDateTime parse​(java.lang.String offsetDateTimeAsString)
        Obtains an instance of TEMPORAL from a string representation in ISO date format.
        Specified by:
        parse in class AbstractTemporalAssert<SELF extends AbstractOffsetDateTimeAssert<SELF>,​java.time.OffsetDateTime>
        Parameters:
        offsetDateTimeAsString - the string to parse, not null
        Returns:
        the parsed TEMPORAL, not null
      • areEqualIgnoringNanos

        private static boolean areEqualIgnoringNanos​(java.time.OffsetDateTime actual,
                                                     java.time.OffsetDateTime other)
        Returns true if both OffsetDateTime are in the same year, month and day of month, hour, minute and second, false otherwise.
        Parameters:
        actual - the actual OffsetDateTime. expected not be null
        other - the other OffsetDateTime. expected not be null
        Returns:
        true if both OffsetDateTime are in the same year, month and day of month, hour, minute and second, false otherwise.
      • areEqualIgnoringSeconds

        private static boolean areEqualIgnoringSeconds​(java.time.OffsetDateTime actual,
                                                       java.time.OffsetDateTime other)
        Returns true if both OffsetDateTime are in the same year, month, day of month, hour and minute, false otherwise.
        Parameters:
        actual - the actual OffsetDateTime. expected not be null
        other - the other OffsetDateTime. expected not be null
        Returns:
        true if both OffsetDateTime are in the same year, month, day of month, hour and minute, false otherwise.
      • areEqualIgnoringMinutes

        private static boolean areEqualIgnoringMinutes​(java.time.OffsetDateTime actual,
                                                       java.time.OffsetDateTime other)
        Returns true if both OffsetDateTime are in the same year, month, day of month and hour, false otherwise.
        Parameters:
        actual - the actual OffsetDateTime. expected not be null
        other - the other OffsetDateTime. expected not be null
        Returns:
        true if both OffsetDateTime are in the same year, month, day of month and hour, false otherwise.
      • haveSameYearMonthAndDayOfMonth

        private static boolean haveSameYearMonthAndDayOfMonth​(java.time.OffsetDateTime actual,
                                                              java.time.OffsetDateTime other)
        Returns true if both OffsetDateTime are in the same year, month and day of month, false otherwise.
        Parameters:
        actual - the actual OffsetDateTime. expected not be null
        other - the other OffsetDateTime. expected not be null
        Returns:
        true if both OffsetDateTime are in the same year, month and day of month, false otherwise
      • haveSameYearAndMonth

        private static boolean haveSameYearAndMonth​(java.time.OffsetDateTime actual,
                                                    java.time.OffsetDateTime other)
        Returns true if both OffsetDateTime are in the same year and month, false otherwise.
        Parameters:
        actual - the actual OffsetDateTime. expected not be null
        other - the other OffsetDateTime. expected not be null
        Returns:
        true if both OffsetDateTime are in the same year and month, false otherwise
      • haveSameYear

        private static boolean haveSameYear​(java.time.OffsetDateTime actual,
                                            java.time.OffsetDateTime other)
        Returns true if both OffsetDateTime are in the same year, false otherwise.
        Parameters:
        actual - the actual OffsetDateTime. expected not be null
        other - the other OffsetDateTime. expected not be null
        Returns:
        true if both OffsetDateTime are in the same year, false otherwise
      • areEqualIgnoringTimezone

        private static boolean areEqualIgnoringTimezone​(java.time.OffsetDateTime actual,
                                                        java.time.OffsetDateTime other)
        Returns true if both OffsetDateTime are in the same hour, minute, second and nanosecond false otherwise.
        Parameters:
        actual - the actual OffsetDateTime. expected not be null
        other - the other OffsetDateTime. expected not be null
        Returns:
        true if both OffsetDateTime are in the same hour, minute, second and nanosecond false otherwise.
      • haveSameNano

        private static boolean haveSameNano​(java.time.OffsetDateTime actual,
                                            java.time.OffsetDateTime other)
        Returns true if both OffsetDateTime are in the same nanosecond, false otherwise.
        Parameters:
        actual - the actual OffsetDateTime. expected not be null
        other - the other OffsetDateTime. expected not be null
        Returns:
        true if both OffsetDateTime are in the same year, false otherwise
      • convertToOffsetDateTimeArray

        private static java.lang.Object[] convertToOffsetDateTimeArray​(java.lang.String... dateTimesAsString)
      • checkIsNotNullAndNotEmpty

        private void checkIsNotNullAndNotEmpty​(java.lang.Object[] values)
      • assertOffsetDateTimeAsStringParameterIsNotNull

        private static void assertOffsetDateTimeAsStringParameterIsNotNull​(java.lang.String offsetDateTimeAsString)
        Check that the OffsetDateTime string representation to compare actual OffsetDateTime to is not null, otherwise throws a IllegalArgumentException with an explicit message
        Parameters:
        offsetDateTimeAsString - String representing the OffsetDateTime to compare actual with
        Throws:
        java.lang.IllegalArgumentException - with an explicit message if the given String is null
      • assertOffsetDateTimeParameterIsNotNull

        private static void assertOffsetDateTimeParameterIsNotNull​(java.time.OffsetDateTime other)
        Check that the OffsetDateTime to compare actual OffsetDateTime to is not null, in that case throws a IllegalArgumentException with an explicit message
        Parameters:
        other - the OffsetDateTime to check
        Throws:
        java.lang.IllegalArgumentException - with an explicit message if the given OffsetDateTime is null