Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Java Program to get the difference between two time zones

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
public class Demo {
	public static void main(String[] args) {
		ZoneId zone1 = ZoneId.of("America/Panama");
		ZoneId zone2 = ZoneId.of("Asia/Taipei");
		LocalDateTime dateTime = LocalDateTime.of(2019, 04, 11, 10, 5);
		ZonedDateTime panamaDateTime = ZonedDateTime.of(dateTime, zone1);
		ZonedDateTime taipeiDateTime = panamaDateTime.withZoneSameInstant(zone2);
		System.out.println("Difference between two time zones in seconds = "+taipeiDateTime.getOffset().getTotalSeconds());
	}
}

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.