Javier Manzano
Javier Manzano

Reputation: 4821

Why this datepicker is not working?

I'm having problems while creating a date picker and I don't know why.... this is the snippet I use:

private static final int DATE_PICKER_DIALOG = 800;


 @Override
protected Dialog onCreateDialog(int id) {
    switch (id) {
    case DATE_PICKER_DIALOG:
        final Calendar calendar = Calendar.getInstance();
        return new DatePickerDialog(getApplicationContext(),
                datePickerCallback, calendar.get(Calendar.YEAR), calendar
                        .get(Calendar.MONTH), calendar
                        .get(Calendar.DAY_OF_MONTH));
    }
    return null;
};

the dialog is called with:

showDialog(DATE_PICKER_DIALOG)

and this is throwing me a IllegalArgumntException: current should be >= start and....

Why is that? thanks!

Upvotes: 0

Views: 129

Answers (1)

Seraphis
Seraphis

Reputation: 1026

Calendar object's month is counting from 0. You are trying to set month in DatePicker to 0 (it's January), but it can be set only to 1-12.

Upvotes: 1

Related Questions