florent37 / SingleDateAndTimePicker

You can now select a date and a time with only one widget !
Apache License 2.0
1.02k stars 334 forks source link

Crash when using mustBeOnFuture() or minDateRange #222

Open ZakiResoluteSolutions opened 5 years ago

ZakiResoluteSolutions commented 5 years ago

When I scroll to past date it shows this error in WheelPicker.java "java.lang.ArithmeticException: divide by zero"

MY CODE:

new SingleDateAndTimePickerDialog.Builder(CheckOutActivity.this)
                            .bottomSheet()
                            .curved()
                            //.minDateRange(Calendar.getInstance().getTime())
                            //.minutesStep(15)
                            .mustBeOnFuture()
                            .mainColor(getResources().getColor(R.color.colorPrimaryDark))
                            .displayListener(new SingleDateAndTimePickerDialog.DisplayListener() {
                                @Override
                                public void onDisplayed(SingleDateAndTimePicker picker) {
                                    //retrieve the SingleDateAndTimePicker
                                }
                            })
                            .title("Order Date")
                            .listener(new SingleDateAndTimePickerDialog.Listener() {
                                @Override
                                public void onDateSelected(Date date) {
                                    SimpleDateFormat source = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                                    SimpleDateFormat source1 = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
                                    String newDate = "";
                                    newDate = source1.format(date);
                                }
                            }).display();