import java.time.LocalTime; import java.time.temporal.ChronoUnit; /** * * @author bogusz.thierry */ public class JavaApplication1 { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here LocalTime h1 = LocalTime.parse("10:45"); LocalTime h2 = LocalTime.parse("12:50"); long m1 = h1.until(h2,ChronoUnit.MINUTES); long m2 = ChronoUnit.MINUTES.between(h1,h2); System.out.println(m1 + ":" + m2); // même résultat ! } }
Mais aussi : https://docs.oracle.com/javase/8/docs/api/java/time/Duration.html