### Question:
DateConverter implements ValueConverter<Date> { public Date convert( String value ) { ParsePosition position = new ParsePosition( 0 ); Date date = formatter.parse( value, position ); if ( position.getIndex() != value.length() ) throw new ValueConversionException( message( value ) ); return date; } DateConverter( DateFormat formatter ); static DateConverter datePattern( String pattern ); Date convert( String value ); Class<Date> valueType(); String valuePattern();  }### Answer:
@Test public void shouldConvertValuesToDatesUsingADateFormat() { ValueConverter<Date> converter = new DateConverter( monthDayYear ); assertEquals( new LocalDate( 2009, 1, 24 ).toDate(), converter.convert( "01/24/2009" ) ); }
@Test public void rejectsNonParsableValues() { thrown.expect( ValueConversionException.class ); new DateConverter( getDateInstance() ).convert( "@(#*^" ); }
@Test public void rejectsValuesThatDoNotEntirelyMatch() { thrown.expect( ValueConversionException.class ); new DateConverter( monthDayYear ).convert( "12/25/09 00:00:00" ); }
@Test public void shouldRaiseExceptionThatContainsDatePatternAndValue() { thrown.expect( ValueConversionException.class ); thrown.expectMessage( "qwe" ); thrown.expectMessage( monthDayYear.toPattern() ); new DateConverter( monthDayYear ).convert( "qwe" ); }
@Test public void shouldRaiseExceptionThatContainsValueOnlyIfNotASimpleDateFormat() { thrown.expect( ValueConversionException.class ); thrown.expectMessage( "asdf" ); thrown.expectMessage( not( containsString( notASimpleDateFormat.toString() ) ) ); new DateConverter( notASimpleDateFormat ).convert( "asdf" ); }