blah.tests.DateConverter Maven / Gradle / Ivy
package blah.tests;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import trip.spi.Provided;
import trip.spi.Singleton;
@Singleton( exposedAs = Converter.class )
public class DateConverter implements Converter {
@Provided( name = "date-format" )
String pattern;
@Override
public Date convert( String string ) throws ConverterException {
try {
SimpleDateFormat formatter = new SimpleDateFormat( this.pattern );
return formatter.parse( string );
} catch ( ParseException cause ) {
throw new ConverterException( cause );
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy