-1

I have two datepicker, one is startTime and other is endTime.

The problem is whenever I use setMinDate function to endTime -> which need larger than startTime. If selected startTime is over the current TIME.

like ->

startTime = 2017/11/17 18:00:00
currentTime(real time) 2017/11/19 15:22:28

It will crash then shows below:

 java.lang.IllegalArgumentException: fromDate: Fri Nov 17 18:00:00 GMT+08:00 2017 does not precede toDate: Fri Nov 17 15:22:28 GMT+08:00 2017

I am pretty sure that I am not passing any miniDate after current, however even the TIME over today but not date, it still crashed.

Can anyone help with this? thanks a lot!

Function called like this.

.setInitialDate(new SimpleDateFormat(DATE_FORMAT_24).parse(mEndTime.getText().toString()))
.setMinDate(new SimpleDateFormat(DATE_FORMAT_24).parse(mStartTime.getText().toString()))
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115

1 Answers1

0

Well, it's all my bad. I actually overwrite a datetimepicker which has minTime&maxTime limitation as well. Therefore I passed a specific time to datepicker. That's why it crash.

What I should do is simply new a Date, pass a date value which has earlier time that current.

And pass the specific date to TimePicker.