-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
35 changed files
with
2,568 additions
and
435 deletions.
There are no files selected for viewing
990 changes: 990 additions & 0 deletions
990
src/main/java/org/exparity/hamcrest/date/OffsetDateTimeMatchers.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/main/java/org/exparity/hamcrest/date/core/function/OffsetDateTimeFunction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package org.exparity.hamcrest.date.core.function; | ||
|
||
import java.time.OffsetDateTime; | ||
import java.time.format.DateTimeFormatter; | ||
import java.time.temporal.ChronoUnit; | ||
import java.util.Locale; | ||
|
||
import org.exparity.hamcrest.date.core.TemporalFunction; | ||
import org.exparity.hamcrest.date.core.TemporalFunctions; | ||
import org.exparity.hamcrest.date.core.types.Interval; | ||
|
||
/** | ||
* Implementation of {@link TemporalFunctions} for {@link OffsetDateTime} objects. | ||
* | ||
* @author Stewart Bissett | ||
*/ | ||
public class OffsetDateTimeFunction implements TemporalFunction<OffsetDateTime> { | ||
|
||
private static final String DATE_TIME_PATTERN = "EEE, dd MMM yyyy hh:mm:ss.SSS a Z"; | ||
|
||
@Override | ||
public boolean isAfter(final OffsetDateTime expected, final OffsetDateTime actual) { | ||
return expected.isAfter(actual); | ||
} | ||
|
||
@Override | ||
public boolean isBefore(final OffsetDateTime expected, final OffsetDateTime actual) { | ||
return expected.isBefore(actual); | ||
} | ||
|
||
@Override | ||
public boolean isSame(final OffsetDateTime expected, final OffsetDateTime actual) { | ||
return expected.equals(actual); | ||
} | ||
|
||
@Override | ||
public Interval interval(OffsetDateTime expected, OffsetDateTime other, ChronoUnit unit) { | ||
return Interval.of(expected.until(other, unit), unit); | ||
} | ||
|
||
@Override | ||
public String describe(final OffsetDateTime temporal, final Locale locale) { | ||
return temporal.format(DateTimeFormatter.ofPattern(DATE_TIME_PATTERN, locale)); | ||
} | ||
} |
Oops, something went wrong.