From bce35ac1d6c4115148468a3240ad459074e0b79e Mon Sep 17 00:00:00 2001 From: Naoto Sato Date: Wed, 10 Nov 2021 20:53:23 +0000 Subject: [PATCH] 8276775: ZonedDateTime/OffsetDateTime.toString return invalid ISO-8601 for years <= 1893 Reviewed-by: lancea, iris, bpb, scolebourne, rriggs --- src/java.base/share/classes/java/time/OffsetDateTime.java | 7 ++++--- src/java.base/share/classes/java/time/ZonedDateTime.java | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/java.base/share/classes/java/time/OffsetDateTime.java b/src/java.base/share/classes/java/time/OffsetDateTime.java index 6587ba33d1339..79131fc699062 100644 --- a/src/java.base/share/classes/java/time/OffsetDateTime.java +++ b/src/java.base/share/classes/java/time/OffsetDateTime.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1897,7 +1897,7 @@ public int hashCode() { /** * Outputs this date-time as a {@code String}, such as {@code 2007-12-03T10:15:30+01:00}. *

- * The output will be one of the following ISO-8601 formats: + * The output will be one of the following formats: *

* The format used will be the shortest that outputs the full value of - * the time where the omitted parts are implied to be zero. + * the time where the omitted parts are implied to be zero. The output + * is compatible with ISO 8601 if the seconds in the offset are zero. * * @return a string representation of this date-time, not null */ diff --git a/src/java.base/share/classes/java/time/ZonedDateTime.java b/src/java.base/share/classes/java/time/ZonedDateTime.java index e7bf2e32b0d14..acd68706b1ca1 100644 --- a/src/java.base/share/classes/java/time/ZonedDateTime.java +++ b/src/java.base/share/classes/java/time/ZonedDateTime.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -2207,7 +2207,8 @@ public int hashCode() { *

* The format consists of the {@code LocalDateTime} followed by the {@code ZoneOffset}. * If the {@code ZoneId} is not the same as the offset, then the ID is output. - * The output is compatible with ISO-8601 if the offset and ID are the same. + * The output is compatible with ISO-8601 if the offset and ID are the same, + * and the seconds in the offset are zero. * * @return a string representation of this date-time, not null */