From: Ivan Frade Date: Tue, 12 Nov 2024 20:29:13 +0000 (-0800) Subject: SystemReader: add method to get LocalDateTime X-Git-Tag: v7.1.0.202411191359-rc1~1^2~9 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=refs%2Fchanges%2F40%2F1204140%2F1;p=jgit.git SystemReader: add method to get LocalDateTime Using #civilNow() because in the documentation, this calendar-based representation is called "civil time". Change-Id: Iaa363e66683cb548419666068a4ffef44a776e12 --- diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java index 7cdf0ee1a2..55cc878e02 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java @@ -26,6 +26,7 @@ import java.nio.file.Paths; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.time.Instant; +import java.time.LocalDateTime; import java.time.ZoneId; import java.time.ZoneOffset; import java.util.Locale; @@ -538,6 +539,17 @@ public abstract class SystemReader { return Instant.ofEpochMilli(getCurrentTime()); } + /** + * Get "now" as civil time, in the System timezone + * + * @return the current system time + * + * @since 7.1 + */ + public LocalDateTime civilNow() { + return LocalDateTime.ofInstant(now(), getTimeZoneId()); + } + /** * Get clock instance preferred by this system. *