java - How do check time within specified Range or not? -
i allowing user select time using timepicker in activity, , getting result in format: 03:51 pm
now have time range - 07:00 pm 10:00 pm
if selected time user matches time defined in time range, need show message "could dangerous"
so know how can check selected time within time range or not ?
i have gone through link
i suggest use jodatime this. it's powerful lib.
joda
can implement below
localtime starttime = localtime.parse("07:00 pm", datetimeformat.forpattern("kk:mm a")); localtime endtime = localtime.parse("10:00 pm", datetimeformat.forpattern("kk:mm a")); localtime selected = new localtime(hourofday, minute); if (selected.isafter(starttime) && selected.isbefore(endtime)) { // work }
Comments
Post a Comment