From f031b33289ea4596e283209decbe70d8d4c809b4 Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Wed, 25 Dec 2024 01:17:03 +0100 Subject: AllowedSigners: use java.time API We are moving away from the old java.util.Date API to the java.time API. Change-Id: I66147445b90df8ca8c8c65239bc9f1ca3f086e75 --- .../org/eclipse/jgit/internal/signing/ssh/AllowedSigners.java | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/signing/ssh/AllowedSigners.java b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/signing/ssh/AllowedSigners.java index cfbe7a78a7..e31ed64ed9 100644 --- a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/signing/ssh/AllowedSigners.java +++ b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/signing/ssh/AllowedSigners.java @@ -21,6 +21,7 @@ import java.text.MessageFormat; import java.time.Instant; import java.time.LocalDate; import java.time.LocalDateTime; +import java.time.ZoneId; import java.time.ZoneOffset; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatterBuilder; @@ -36,8 +37,6 @@ import java.util.Locale; import java.util.Map; import java.util.Objects; import java.util.Set; -import java.util.TimeZone; -import java.util.concurrent.TimeUnit; import java.util.function.Predicate; import java.util.stream.Collectors; @@ -482,12 +481,8 @@ final class AllowedSigners extends ModifiableFileWatcher { if (isUTC) { return time.atOffset(ZoneOffset.UTC).toInstant(); } - TimeZone tz = SystemReader.getInstance().getTimeZone(); - // Since there are a few TimeZone IDs that are not recognized by ZoneId, - // use offsets. - return time.atOffset(ZoneOffset.ofTotalSeconds( - (int) TimeUnit.MILLISECONDS.toSeconds(tz.getRawOffset()))) - .toInstant(); + ZoneId tz = SystemReader.getInstance().getTimeZoneId(); + return time.atZone(tz).toInstant(); } // OpenSSH uses the backslash *only* to quote the double-quote. -- cgit v1.2.3