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