diff --git a/core-java-8/src/main/java/com/baeldung/util/GetCurrentTime.java b/core-java-8/src/main/java/com/baeldung/util/GetCurrentTime.java new file mode 100644 index 0000000000..39934c94bf --- /dev/null +++ b/core-java-8/src/main/java/com/baeldung/util/GetCurrentTime.java @@ -0,0 +1,20 @@ +package com.baeldung.util; + +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.ZoneId; + +public class GetCurrentTime { + + public static void main(String args[]) { + + LocalTime localTime = LocalTime.now(); + System.out.println("Current time is: " + localTime); + + localTime = LocalTime.now(ZoneId.of("GMT+02:30")); + System.out.println("Current time in GMT +02:30 timezone: " + localTime); + + LocalDateTime localDateTime = LocalDateTime.now(); + System.out.println("Current time is: " + localDateTime.toLocalTime()); + } +}