All Downloads are FREE. Search and download functionalities are using the official Maven repository.

blah.tests.DateConverter Maven / Gradle / Ivy

There is a newer version: 2.1.0
Show newest version
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