@IgnoreBrowser(value = "internet.*", version = "9\\.*", reason="See http://jira.xwiki.org/browse/XE-1177")
})
public void testDateFormat()
{
// Add a date field and change the date format.
DateClassFieldEditPane dateField = new DateClassFieldEditPane(editor.addField("Date").getName());
dateField.openConfigPanel();
String dateFormat = "yyyy.MM.dd";
dateField.setDateFormat(dateFormat);
// Close the configuration panel to refresh the date field preview.
dateField.closeConfigPanel();
// Select a date using the date picker.
DatePicker datePicker = dateField.openDatePicker();
// The current date format doesn't include time information.
Assert.assertFalse(datePicker.hasHourSelector());
datePicker.setDay("22");
Calendar now = Calendar.getInstance();
now.set(Calendar.DAY_OF_MONTH, 22);
Assert.assertEquals(new SimpleDateFormat(dateFormat).format(now.getTime()), dateField.getDefaultValue());
// Test if the date picker knows how to parse dates with a custom date format.
// Set the value of the date input and assert the date selected by the picker.
dateField.setDefaultValue("2012.11.10");
// Currently the date picker doesn't know how to parse a date with a specified format. The workaround is to pass
// the date time stamp when generating the date input, but for this the page needs to be saved and reloaded.
editor.clickSaveAndView().edit();
datePicker = new DateClassFieldEditPane("date1").openDatePicker();
Assert.assertEquals("2012", datePicker.getYear());
Assert.assertEquals("November", datePicker.getMonth());
Assert.assertEquals("10", datePicker.getDay());
Assert.assertFalse(datePicker.hasHourSelector());