get Travel Time by ZonedDateTime - Java java.time

Java examples for java.time:ZonedDateTime

Description

get Travel Time by ZonedDateTime

Demo Code


//package com.java2s;
import java.time.Duration;

import java.time.ZonedDateTime;

public class Main {
    public static Duration getTravelTime(ZonedDateTime fromZonedDateTime,
            ZonedDateTime toZonedDateTime) {
        fromZonedDateTime = fromZonedDateTime
                .withZoneSameInstant(toZonedDateTime.getZone());
        return Duration.between(fromZonedDateTime, toZonedDateTime);
    }/*from w w w  .  j  a v  a2  s .c  om*/
}

Related Tutorials