Reputation: 1
I need to compare two times which would then give a user a specific access i.e. if the time is between 8:30 and 10:30 then the access is granted and the system.out.println
would say "Access granted". Thanks for help in advance
Upvotes: 0
Views: 260
Reputation: 761
LocalTime, which seems to be your implementation (your code does not include the imports) implements Comparable, so you can just use the method compareTo.
Upvotes: 1
Reputation: 106
Edit: the answer from awesome is probably a lot easier dont mind mine
Youre code is quite hard to read to be honest, considering the source code is not complete. Anyway, to answer your question, you should probably use the class Date which Features a method called after
Upvotes: 0
Reputation: 2153
You already have isLate
and isBefore
in your code. You only need to determine that both are false.
if(!isLate && !isBefore ){
System.out.println("Access granted");
}
Upvotes: 1