how to compare time from sysytem time in android

Solutions on MaxInterview for how to compare time from sysytem time in android by the best coders in the world

showing results for - "how to compare time from sysytem time in android"
Timothée
28 Jan 2017
1SimpleDateFormat inputParser = new SimpleDateFormat(inputFormat, Locale.US);
2
3private void compareDates(){
4    Calendar now = Calendar.getInstance();
5
6    int hour = now.get(Calendar.HOUR);
7    int minute = now.get(Calendar.MINUTE);
8
9    date = parseDate(hour + ":" + minute);
10    dateCompareOne = parseDate(compareStringOne);
11    dateCompareTwo = parseDate(compareStringTwo);
12
13    if ( dateCompareOne.before( date ) && dateCompareTwo.after(date)) {
14        //yada yada
15    }
16}
17
18private Date parseDate(String date) {
19
20    try {
21        return inputParser.parse(date);
22    } catch (java.text.ParseException e) {
23        return new Date(0);
24    }
25}
26