diff options
author | Ivan Frade <ifrade@google.com> | 2024-11-12 12:29:13 -0800 |
---|---|---|
committer | Ivan Frade <ifrade@google.com> | 2024-11-14 12:45:51 -0800 |
commit | b7856f885bf02af20b07359823396a92ffa6e76e (patch) | |
tree | 929a3b5e7091976685bea80d2c6a730a5aee99ed /org.eclipse.jgit/src | |
parent | c67393562be7e3db0e39cb2d3ff5f8192e2f2cd5 (diff) | |
download | jgit-b7856f885bf02af20b07359823396a92ffa6e76e.tar.gz jgit-b7856f885bf02af20b07359823396a92ffa6e76e.zip |
SystemReader: add method to get LocalDateTime
Using #civilNow() because in the documentation, this calendar-based
representation is called "civil time".
Change-Id: Iaa363e66683cb548419666068a4ffef44a776e12
Diffstat (limited to 'org.eclipse.jgit/src')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java | 12 |
1 files changed, 12 insertions, 0 deletions
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; @@ -539,6 +540,17 @@ public abstract class SystemReader { } /** + * 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. * * @return clock instance preferred by this system. |