We would like to know how to find duration between local date time and data time in another timezone.
import java.time.Duration; import java.time.LocalDateTime; import java.time.Month; import java.time.ZoneId; import java.time.ZonedDateTime; /* ww w.j a v a 2s. co m*/ public class Main { public static void main(String[] args) { LocalDateTime l = LocalDateTime.of(2012, Month.AUGUST, 13, 0, 0, 0); ZonedDateTime z = ZonedDateTime.of(LocalDateTime.of(2014, Month.AUGUST, 13, 0, 0, 0), ZoneId.of("America/Los_Angeles")); Duration duration = Duration.between(l,z); System.out.println(duration); } }
The code above generates the following result.