diff options
author | Ivan Frade <ifrade@google.com> | 2024-12-10 19:05:05 +0000 |
---|---|---|
committer | Gerrit Code Review <support@gerrithub.io> | 2024-12-10 19:05:05 +0000 |
commit | ec9f955204ebbeb43d283d3980a83a74e649e4f9 (patch) | |
tree | b4044b50e4ad7faf1c45f132786d306f56b94640 | |
parent | 6caf5c8693282a88adf32fbff278e2cd08d1d2a4 (diff) | |
parent | 76274b62a2cf4da2feb1ac7e9ed6c982d9d3f087 (diff) | |
download | jgit-ec9f955204ebbeb43d283d3980a83a74e649e4f9.tar.gz jgit-ec9f955204ebbeb43d283d3980a83a74e649e4f9.zip |
Merge "PersonIdent: Default to UTC in timezone parsing"
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/lib/PersonIdent.java | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/PersonIdent.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/PersonIdent.java index 5d3db9e6ee..f22642c4ce 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/PersonIdent.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/PersonIdent.java @@ -12,7 +12,10 @@ package org.eclipse.jgit.lib; +import static java.time.ZoneOffset.UTC; + import java.io.Serializable; +import java.time.DateTimeException; import java.time.Instant; import java.time.ZoneId; import java.time.ZoneOffset; @@ -54,11 +57,15 @@ public class PersonIdent implements Serializable { * Translate a minutes offset into a ZoneId * * @param tzOffset as minutes east of UTC - * @return a ZoneId for this offset + * @return a ZoneId for this offset (UTC if invalid) * @since 7.1 */ public static ZoneId getZoneId(int tzOffset) { - return ZoneOffset.ofHoursMinutes(tzOffset / 60, tzOffset % 60); + try { + return ZoneOffset.ofHoursMinutes(tzOffset / 60, tzOffset % 60); + } catch (DateTimeException e) { + return UTC; + } } /** |