Java Data Type How to - Get Difference Between Paris And London in hours








Question

We would like to know how to get Difference Between Paris And London in hours.

Answer

import java.time.ZoneId;
import java.time.ZonedDateTime;
//w  ww.ja v a  2s. c  o m
public class Main {
  public static void main(String[] argv) {
    ZonedDateTime paris = ZonedDateTime.now(ZoneId.of("Europe/Paris"));
    ZonedDateTime london = ZonedDateTime.now(ZoneId.of("Europe/London"));
    System.out.println(paris.getHour() - london.getHour());
  }
}

The code above generates the following result.