30 lines
625 B
Plaintext
Executable File
30 lines
625 B
Plaintext
Executable File
package com.fp.dto.json.morpher;
|
|
|
|
import java.sql.Date;
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import com.fp.dto.json.DateValueProcessor;
|
|
|
|
import net.sf.ezmorph.object.AbstractObjectMorpher;
|
|
|
|
public class DateMorpher extends AbstractObjectMorpher {
|
|
|
|
public Object morph(Object pValue) {
|
|
if(pValue instanceof Date){
|
|
return (Date)pValue;
|
|
}
|
|
try{
|
|
if(pValue instanceof String){
|
|
return new Date( new SimpleDateFormat(DateValueProcessor.DATE_TRANSPORT).parse((String)pValue).getTime());
|
|
}
|
|
}catch(Exception e){}
|
|
return null;
|
|
}
|
|
|
|
@SuppressWarnings("unchecked")
|
|
public Class morphsTo() {
|
|
return Date.class;
|
|
}
|
|
|
|
}
|