Java LocalTime get hours elapsed between two LocalTime values

Description

Java LocalTime get hours elapsed between two LocalTime values

import java.time.LocalTime;
import java.time.temporal.ChronoUnit;

public class Main {
  public static void main(String[] args) {
     /* w w  w  .  j  a  v  a  2  s.  c om*/
     LocalTime lt1 = LocalTime.of(7, 0);
     LocalTime lt2 = LocalTime.of(9, 30);


     long hours = lt1.until(lt2, ChronoUnit.HOURS);
     System.out.println(hours);

  }
}



PreviousNext

Related