michaldrabik / classicmaterialtimepicker

Classic Material Time Picker
57 stars 10 forks source link

When we set initial date with calendar object it create an Exception (Bug) #8

Closed malikbilal1997 closed 3 years ago

malikbilal1997 commented 3 years ago

`
Date date = new Date();

    Calendar calendar = Calendar.getInstance();

    calendar.setTime(date);

   cmtpDateDialogFragment.setInitialDate(calendar);

`

java.lang.IllegalStateException: Invalid month. Must be between 1 and 12

michaldrabik commented 3 years ago

@malikbilal1997 Thanks, I'll check this when I get a chance.

malikbilal1997 commented 3 years ago

@malikbilal1997 Thanks, I'll check this when I get a chance.

Sure for work around i'm setting date manually.

` Calendar calendar = Calendar.getInstance();

    calendar.setTime(new Date());

    int day = calendar.get(Calendar.DAY_OF_MONTH);

    int month = calendar.get(Calendar.MONTH) + 1;

    int year = calendar.get(Calendar.YEAR);

    cmtpDateDialogFragment.setInitialDate(day, month, year);

`

michaldrabik commented 3 years ago

Fixed and released in version 1.1.2 which is now available to use.