Skip to content

Instantly share code, notes, and snippets.

@bmnepali
Created March 20, 2020 03:09
Show Gist options
  • Save bmnepali/84cb123d6fa6f0218fbd7153e9f6d2a8 to your computer and use it in GitHub Desktop.
Save bmnepali/84cb123d6fa6f0218fbd7153e9f6d2a8 to your computer and use it in GitHub Desktop.
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