package com.bradmcevoy.http.values;

import com.bradmcevoy.http.DateUtils;
import com.bradmcevoy.http.DateUtils.DateParseException;
import com.bradmcevoy.http.XmlWriter;
import java.util.Date;
import java.util.Map;

public class DateValueWriter implements ValueWriter {

    public boolean supports( String nsUri, String localName, Class c ) {
        return Date.class.equals( c );
    }

    public void writeValue( XmlWriter writer, String nsUri, String prefix, String localName, Object val, String href, Map<String, String> nsPrefixes ) {
        if( val == null ) {
            writer.writeProperty( prefix, localName );
        } else {
            Date date = (Date) val;
            String s = DateUtils.formatDate( date );
            writer.writeProperty( prefix, localName, s );
        }
    }

    public Object parse( String namespaceURI, String localPart, String value ) {
        if( value == null || value.length() == 0 ) return null;
        Date dt;
        try {
            dt = DateUtils.parseDate( value );
            return dt;
        } catch( DateParseException ex ) {
            throw new RuntimeException( value, ex );
        }
    }
}

@@ -264,16 +264,27 @@
 iter %7B%0A%0A
+%09@Override%0A
     publ
@@ -367,39 +367,42 @@
 urn 
-Date.class.equals( c 
+c.isInstance(Date.class
 );
+ 
 %0A    %7D%0A%0A
     
@@ -389,32 +389,43 @@
 class); %0A    %7D%0A%0A
+%09@Override%0A
     public void 
@@ -825,16 +825,27 @@
 %0A    %7D%0A%0A
+%09@Override%0A
     publ

Fix so that Timestamp objects get formatted as Date's