use of org.odk.collect.android.widgets.DateTimeWidget in project collect by opendatakit.
the class DaylightSavingTest method prepareDateTimeWidget.
private DateTimeWidget prepareDateTimeWidget(int year, int month, int day, int hour, int minute) {
QuestionDef questionDefStub = mock(QuestionDef.class);
IFormElement iformElementStub = mock(IFormElement.class);
FormEntryPrompt formEntryPromptStub = mock(FormEntryPrompt.class);
when(iformElementStub.getAdditionalAttribute(anyString(), anyString())).thenReturn(null);
when(formEntryPromptStub.getQuestion()).thenReturn(questionDefStub);
when(formEntryPromptStub.getFormElement()).thenReturn(iformElementStub);
when(formEntryPromptStub.getQuestion().getAppearanceAttr()).thenReturn("no-calendar");
DateWidget dateWidget = mock(DateWidget.class);
when(dateWidget.getDate()).thenReturn(new LocalDateTime().withYear(year).withMonthOfYear(month).withDayOfMonth(day));
TimeWidget timeWidget = mock(TimeWidget.class);
when(timeWidget.getHour()).thenReturn(hour);
when(timeWidget.getMinute()).thenReturn(minute);
DateTimeWidget dateTimeWidget = new DateTimeWidget(RuntimeEnvironment.application, formEntryPromptStub);
dateTimeWidget.setDateWidget(dateWidget);
dateTimeWidget.setTimeWidget(timeWidget);
return dateTimeWidget;
}
use of org.odk.collect.android.widgets.DateTimeWidget in project collect by opendatakit.
the class DaylightSavingTest method testESTTimeZoneWithDateTimeWidget.
@Test
public // 26 Mar 2017 at 02:00:00 clocks were turned forward to 03:00:00.
void testESTTimeZoneWithDateTimeWidget() {
TimeZone.setDefault(TimeZone.getTimeZone(CET_TIME_ZONE));
DateTimeWidget dateTimeWidget = prepareDateTimeWidget(2017, 3, 26, 2, 30);
/*
* We would get crash in this place using old approach {@link org.joda.time.DateTime} instead of
* {@link org.joda.time.LocalDateTime}
*/
dateTimeWidget.getAnswer();
}
Aggregations