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

org.codehaus.xfire.aegis.type.basic.CalendarType Maven / Gradle / Ivy

package org.codehaus.xfire.aegis.type.basic;

import java.text.ParseException;

import org.codehaus.xfire.MessageContext;
import org.codehaus.xfire.aegis.MessageReader;
import org.codehaus.xfire.aegis.MessageWriter;
import org.codehaus.xfire.aegis.type.Type;
import org.codehaus.xfire.fault.XFireFault;
import org.codehaus.xfire.util.date.XsDateTimeFormat;

/**
 * Type for the Calendar class.
 * 
 * @author Dan Diephouse
 */
public class CalendarType
    extends Type
{
    private static XsDateTimeFormat format = new XsDateTimeFormat();
    
    public Object readObject(MessageReader reader, MessageContext context) throws XFireFault
    {
        String value = reader.getValue();
        
        if (value == null) return null;
        
        try
        {
            return format.parseObject(value);
        }
        catch (ParseException e)
        {
            throw new XFireFault("Could not parse xs:dateTime: " + e.getMessage(), e, XFireFault.SENDER);
        }
    }

    public void writeObject(Object object, MessageWriter writer, MessageContext context)
    {
        writer.writeValue(format.format(object));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy