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

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -