]> source.dussan.org Git - jgit.git/commitdiff
SystemReader: add method to get LocalDateTime 40/1204140/1
authorIvan Frade <ifrade@google.com>
Tue, 12 Nov 2024 20:29:13 +0000 (12:29 -0800)
committerIvan Frade <ifrade@google.com>
Thu, 14 Nov 2024 20:45:51 +0000 (12:45 -0800)
Using #civilNow() because in the documentation, this calendar-based
representation is called "civil time".

Change-Id: Iaa363e66683cb548419666068a4ffef44a776e12

org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java

index 7cdf0ee1a28a6d34de7f5a61136a9e25670e3597..55cc878e02f00e0dfe39a756b5ba5146e50d364d 100644 (file)
@@ -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.
         *