CalendarCombo java.lang.NumberFormatException [message #526913] |
Tue, 13 April 2010 13:36 |
|
Hi,
I am using the CalendarCombo. If I write letters instead of the enteir date, I can catch the exception in the DateParseExceptionListener. However if I leave the date as it is and just add a few letters at the end (e.g. 04/13/2010ede), I get a NumberFormatException in the stderr and I am not able to catch the exception. I did a workaround and added a FocusListener that whenever the combo looses the focus, it does m_validTill.setDate(m_validTill.getDate());, which hides the error from the user, but I still get the exception in the stderr. Is there any way to catch the exception?
Thanks,
Nir.
Here is my code:
m_validTill = new CalendarCombo(cAutoOrderQnt, SWT.NONE, false);
m_validTill.setLayoutData(new GridData(SWT.BEGINNING, SWT.FILL, true, false, 1, 1));
m_validTill.setDate(SysCfg.Todday);
m_validTill.setDisallowBeforeDate(SysCfg.Todday);
m_validTill.addFocusListener(new FocusListener() {
@Override
public void focusLost(FocusEvent e) {
//in order to remove any user error like 13/04/2010ddd which for some reason doesn't throw a DateParseException, but sends an exception to the stderr
m_validTill.setDate(m_validTill.getDate());
}
@Override
public void focusGained(FocusEvent e) {
//do nothing
}
});
m_validTill.addDateParseExceptionListener(new IDateParseExceptionListener() {
@Override
public void parseExceptionThrown(CalendarDateParseException dateParseException) {
m_validTill.setDate(SysCfg.Todday);
m_validTill.setDisallowBeforeDate(SysCfg.Todday);
}
});
|
|
|
Powered by
FUDForum. Page generated in 0.02947 seconds