How can I determine if the current time is between two other time objects?
For example: current: 15:23, startTime: 22:00, endTime: 06:00. So the current time is not between this two other times, but this “23:47” is.
*I don’t care about the date only the time
I tried to do it like this:
Time startTime = getStartTime();
Time endTime = getEndTime();
Calendar c = Calendar.getInstance();
Time now = new Time(c.getTimeInMillis());
if (now.before(endTime) && now.after(startTime)) {
return true;
}
return false;
but it dosen’t work well. their aren’t any error but it just dosen’t work.
To be more precise the problem is that 15:35.after(22:00) return true… and I don’t know why.
I think that the problem is something with the dates but I don’t know what
I found a solution: