@Test
public void shouldBindFormattedValueToModel() throws Exception
{
// given
JFormattedTextField textField = new JFormattedTextField(new DateFormatter());
ModelForTests model = new ModelForTests();
bind().valueOf(textField).to(model, ModelForTests.DATE);
Calendar calendar = Calendar.getInstance();
calendar.set(2010, 4, 10);
// when
textField.setText(textField.getFormatter().valueToString(calendar.getTime()));
textField.commitEdit();
// then
assertNotNull(model.getDate());
calendar.setTime(model.getDate());
assertEquals(2010, calendar.get(Calendar.YEAR));
assertEquals(4, calendar.get(Calendar.MONTH));
assertEquals(10, calendar.get(Calendar.DAY_OF_MONTH));
}