Java LocalTime get hours between two LocalTime values using until method

Description

Java LocalTime get hours between two LocalTime values using until method


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

public class Main {
  public static void main(String[] args) {
    LocalTime lt1 = LocalTime.of(7, 0);
    LocalTime lt2 = LocalTime.of(9, 30);

    long hours = lt1.until(lt2, ChronoUnit.HOURS);
    System.out.println(hours);/* w  w w . j  ava 2 s . c o m*/
  }
}



PreviousNext

Related