@Test public void testValidate() { DatePM model = new DatePM(); model.setText("14.01.1971"); assertEquals("pM.isValid()", true, model.isValid()); model.setText("31.02"); assertEquals("pM.isValid()", false, model.isValid()); model.setText("aaa"); assertEquals("pM.isValid()", false, model.isValid()); try { model.getDate(); fail("ecpected ConversionException"); } catch (ConversionException ex) { } model.setText("14.01.1971a"); assertEquals("pM.isValid()", false, model.isValid()); try { model.getDate(); fail("ecpected ConversionException"); } catch (ConversionException ex) { } }
public Date getDate() throws ConversionException { if (isEmpty()) { return null; } String str = getText(); ParsePosition posInOut = new ParsePosition(0); Date result = (Date)format.parseObject(str, posInOut); if (posInOut.getIndex() == str.length()) { return result; } else { throw new ConversionException(); } }
DatePM extends TextPM implements IDatePM { public Date getDate() throws ConversionException { if (isEmpty()) { return null; } String str = getText(); ParsePosition posInOut = new ParsePosition(0); Date result = (Date)format.parseObject(str, posInOut); if (posInOut.getIndex() == str.length()) { return result; } else { throw new ConversionException(); } } }
DatePM extends TextPM implements IDatePM { public Date getDate() throws ConversionException { if (isEmpty()) { return null; } String str = getText(); ParsePosition posInOut = new ParsePosition(0); Date result = (Date)format.parseObject(str, posInOut); if (posInOut.getIndex() == str.length()) { return result; } else { throw new ConversionException(); } } DatePM(); }
DatePM extends TextPM implements IDatePM { public Date getDate() throws ConversionException { if (isEmpty()) { return null; } String str = getText(); ParsePosition posInOut = new ParsePosition(0); Date result = (Date)format.parseObject(str, posInOut); if (posInOut.getIndex() == str.length()) { return result; } else { throw new ConversionException(); } } DatePM(); static synchronized DateFormatProvider getDefaultDateFormatProvider(); static synchronized void setDefaultDateFormatProvider(DateFormatProvider provider); DateFormat getFormat(); void setFormat(DateFormat newFormat); Date getDate(); void setDate(Date date); void setDefaultDate(Date date); @Override Comparable<?> getComparable(); }
DatePM extends TextPM implements IDatePM { public Date getDate() throws ConversionException { if (isEmpty()) { return null; } String str = getText(); ParsePosition posInOut = new ParsePosition(0); Date result = (Date)format.parseObject(str, posInOut); if (posInOut.getIndex() == str.length()) { return result; } else { throw new ConversionException(); } } DatePM(); static synchronized DateFormatProvider getDefaultDateFormatProvider(); static synchronized void setDefaultDateFormatProvider(DateFormatProvider provider); DateFormat getFormat(); void setFormat(DateFormat newFormat); Date getDate(); void setDate(Date date); void setDefaultDate(Date date); @Override Comparable<?> getComparable();  }