Created
March 20, 2020 03:09
-
-
Save bmnepali/84cb123d6fa6f0218fbd7153e9f6d2a8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.time.LocalTime; | |
import java.time.ZoneId; | |
import java.time.ZoneOffset; | |
import java.time.ZonedDateTime; | |
public class HelloWorld{ | |
public static void main(String []args){ | |
System.out.println("Hello World"); | |
LocalTime time = LocalTime.parse("10:00:00"); // 10 AM | |
ZonedDateTime utc = ZonedDateTime | |
.now(ZoneId.of("Asia/Calcutta")) // current date/time in India | |
.with(time) // set time to 10 AM | |
.withZoneSameInstant(ZoneOffset.UTC); // convert to UT | |
System.out.println("Time in UTC: " + utc); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment