I have a function to show an alert if time is between two values.
Eg:
start = 07:00:00
end = 17:00:00
assert start != null;
int from = Integer.valueOf(start.replace(":", ""));
assert end != null;
int to = Integer.valueOf(end.replace(":", ""));
Date date = new Date();
Calendar c = Calendar.getInstance();
c.setTime(date);
int t = c.get(Calendar.HOUR_OF_DAY) * 100 + c.get(Calendar.MINUTE);
boolean isBetween = to > from && t >= from && t <= to || to < from && (t >= from || t <= to);
a = isBetween ? 1 : 0;
if(a == 1) {
alert_f();
// a is never 1...
}
The problem is the a
is never 1, even when the actual time is between the start and the end one.
any ideas why?