/** You may copy this example and use it for any purpose, commercial or otherwise. */ import com.ricebridge.data.sc.DefaultStringConverter; import java.text.DateFormat; import java.util.Date; /** This utility class shows how to implement a StringConverter for * custom conversion of textual data into Java data types. It converts * dates in the format 2007-12-31 into java.util.Date objects. * * To compile this class, you will need to include xmlman.jar * (in the lib folder of the XML Manager distribution) in your CLASSPATH. */ public class DateConverter extends DefaultStringConverter { private Date iDefault = new Date(); private DateFormat iDateFormat = null; /** Create a DateConverter based on a specific date format. */ public DateConverter( DateFormat pDateFormat ) { iDateFormat = pDateFormat; } /** Create a Date object from a String. */ protected Object makeObjectImpl( String pValue ) throws Exception { return iDateFormat.parse(pValue); } /** Return the default Date object. */ protected Object makeDefaultObjectImpl() { return new Date(); } /** Create a String from a Date object. */ protected String makeStringImpl( Object pValue ) throws Exception { return iDateFormat.format((Date)pValue); } /** Return the default String. */ protected String makeDefaultStringImpl() { return new Date().toString(); } }