1. 程式人生 > >DatePicker 設定最小日期是當前時間報錯:java.lang.IllegalArgumentException: fromDate:xxx does not preced toDate: xx

DatePicker 設定最小日期是當前時間報錯:java.lang.IllegalArgumentException: fromDate:xxx does not preced toDate: xx

fromDate: Tue Jul 04 11:42:14 EDT 2017 does not precede toDate: Tue Jul 04 11:42:14 EDT 2017

解決:設定最小時間是當前時間必須要減去一定值,否則判斷會報錯。

//設定最小日期是當前的時間必須這樣。否則報錯
        date_picker.setMinDate(calendar.getTimeInMillis()-1000);