Skip to content

Commit 7661f0a

Browse files
committed
add zone string test
1 parent 685a3e9 commit 7661f0a

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

java-core/google-cloud-core/src/main/java/com/google/cloud/Timestamp.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public final class Timestamp implements Comparable<Timestamp>, Serializable {
5555
new DateTimeFormatterBuilder()
5656
.appendOptional(DateTimeFormatter.ISO_LOCAL_DATE_TIME)
5757
.optionalStart()
58-
.appendOffset("+HH:MM", "Z")
58+
.appendZoneOrOffsetId()
5959
.optionalEnd()
6060
.toFormatter()
6161
.withZone(ZoneOffset.UTC);

java-core/google-cloud-core/src/test/java/com/google/cloud/TimestampTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,12 @@ void parseTimestampWithTimeZoneOffset() {
251251
.isEqualTo(Timestamp.parseTimestamp("2020-12-06T19:21:12.123+05:30"));
252252
}
253253

254+
@Test
255+
void parseTimestampWithZoneString() {
256+
assertThat(Timestamp.parseTimestampDuration("2020-12-06T08:51:12.123America/Toronto"))
257+
.isEqualTo(Timestamp.ofTimeSecondsAndNanos(1607262672, 123000000));
258+
}
259+
254260
@Test
255261
void fromProto() {
256262
com.google.protobuf.Timestamp proto =

0 commit comments

Comments
 (0)