I would like to notify the user if the user selects time lesser than the current one,I do not want to show it on time picker UI,only notify the user. Following is my current code.
final int mHour, mMinute;
final Calendar c = Calendar.getInstance();
mHour = c.get(Calendar.HOUR_OF_DAY);
mMinute = c.get(Calendar.MINUTE);
hour = c.get(Calendar.HOUR);
//if()
// Launch Time Picker Dialog
TimePickerDialog timePickerDialog = new TimePickerDialog(mainActivity, new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
if (hourOfDay >= mHour) {
String strTime = hourOfDay + ":" + minute + ":00";
renewalTime.setText(strTime);
} else {
Toast.makeText(mainActivity, "Time cannot be lesser than current time", Toast.LENGTH_LONG).show();
}
}
}, mHour, mMinute, false);
timePickerDialog.show();
}
so currently what is happening is if the current time is 12 PM or onwards, it takes values as 12,1 and so on and for 11 am it takes 23 and so on..so how to compare them in either case ? Thank you.