[Solved] Java time variable [duplicate]


The LocalTime class represents a time of day, without any date component. That seems to be the class you want to use here.

You can create LocalTime objects with LocalTime.of, and compare them with isBefore and isAfter. Like this.

LocalTime sevenThirty = LocalTime.of(7,30);
LocalTime eightTwenty = LocalTime.of(8,20);
LocalTime nineOClock = LocalTime.of(9,0);

if(eightTwenty.isAfter(sevenThirty) && eightTwenty.isBefore(nineOClock)) {
    System.out.println("8:20 is between 7:30 and 9:00");
}

2

solved Java time variable [duplicate]