org.codehaus.jackson.map.ser.std.TimeZoneSerializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ehcache Show documentation
Show all versions of ehcache Show documentation
Ehcache is an open source, standards-based cache used to boost performance,
offload the database and simplify scalability. Ehcache is robust, proven and full-featured and
this has made it the most widely-used Java-based cache.
package org.codehaus.jackson.map.ser.std;
import java.io.IOException;
import java.util.TimeZone;
import org.codehaus.jackson.JsonGenerationException;
import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.map.SerializerProvider;
import org.codehaus.jackson.map.TypeSerializer;
/**
* @since 1.8
*/
public class TimeZoneSerializer
extends ScalarSerializerBase
{
public final static TimeZoneSerializer instance = new TimeZoneSerializer();
public TimeZoneSerializer() { super(TimeZone.class); }
@Override
public void serialize(TimeZone value, JsonGenerator jgen, SerializerProvider provider)
throws IOException, JsonGenerationException
{
jgen.writeString(value.getID());
}
@Override
public void serializeWithType(TimeZone value, JsonGenerator jgen, SerializerProvider provider,
TypeSerializer typeSer)
throws IOException, JsonGenerationException
{
// Better ensure we don't use specific sub-classes:
typeSer.writeTypePrefixForScalar(value, jgen, TimeZone.class);
serialize(value, jgen, provider);
typeSer.writeTypeSuffixForScalar(value, jgen);
}
}