@Test
public void testCalendarFromPicker() throws Exception {

    datePickerDialog.yearPicker.setValue(2016 + 543);
    datePickerDialog.monthPicker.setValue(MARCH);
    datePickerDialog.dayPicker.setValue(31);
    Calendar newCalendar = datePickerDialog.newCalendarFromPicker();
    assertEquals(31, newCalendar.get(DAY_OF_MONTH));
    assertEquals(MARCH, newCalendar.get(MONTH));
    assertEquals(2016, newCalendar.get(YEAR));
    assertEquals(31, newCalendar.getActualMaximum(DAY_OF_MONTH));
    datePickerDialog.monthPicker.setValue(FEBRUARY);
    newCalendar = datePickerDialog.newCalendarFromPicker();
    assertEquals(29, newCalendar.get(DAY_OF_MONTH));
}