Skip to content

Commit

Permalink
chore: demo offset parsing tests in java-core + java.time
Browse files Browse the repository at this point in the history
  • Loading branch information
diegomarquezp committed Nov 7, 2024
1 parent b67db50 commit 26437b7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ public final class Timestamp implements Comparable<Timestamp>, Serializable {
new DateTimeFormatterBuilder()
.appendOptional(DateTimeFormatter.ISO_LOCAL_DATE_TIME)
.optionalStart()
.appendZoneOrOffsetId()
// .appendZoneOrOffsetId()
.appendOffsetId()
.optionalEnd()
.toFormatter()
.withZone(ZoneOffset.UTC);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,18 @@ void parseTimestampWithTimeZoneOffset() {
() -> Timestamp.parseTimestampDuration("2016-12-31T23:59:60Z"));
}

@Test
void demoAssertion1() {
assertThat(Timestamp.parseTimestampDuration("2020-07-10T14:03:00.123-07:00"))
.isEqualTo(Timestamp.ofTimeSecondsAndNanos(1594414980, 123000000));
}

@Test
void demoAssertion2() {
assertThat(Timestamp.parseTimestampDuration("2020-12-06T19:21:12.123+05:30"))
.isEqualTo(Timestamp.ofTimeSecondsAndNanos(1607262672, 123000000));
}

@Test
void parseTimestampWithZoneString() {
// Valid RFC 3339 timestamps with time zone names
Expand Down

0 comments on commit 26437b7

Please sign in to comment.