Sha256: 7be3f42f4faed4f23256243f57c5dc164e86fed663e24bd7acfa614032278437

Contents?: true

Size: 1.6 KB

Versions: 104

Compression:

Stored size: 1.6 KB

Contents

package org.embulk.spi.time;

import java.io.IOException;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.deser.std.FromStringDeserializer;
import com.fasterxml.jackson.module.guice.ObjectMapperModule;

public class TimestampSerDe
{
    public static void configure(ObjectMapperModule mapper)
    {
        SimpleModule module = new SimpleModule();
        module.addSerializer(Timestamp.class, new DateTimeZoneSerializer());
        module.addDeserializer(Timestamp.class, new DateTimeZoneDeserializer());
        mapper.registerModule(module);
    }

    public static class DateTimeZoneSerializer
            extends JsonSerializer<Timestamp>
    {
        @Override
        public void serialize(Timestamp value, JsonGenerator jgen, SerializerProvider provider)
                throws IOException
        {
            jgen.writeString(value.toString());
        }
    }

    public static class DateTimeZoneDeserializer
            extends FromStringDeserializer<Timestamp>
    {
        public DateTimeZoneDeserializer()
        {
            super(Timestamp.class);
        }

        @Override
        protected Timestamp _deserialize(String value, DeserializationContext context)
                throws JsonMappingException
        {
            return Timestamp.fromString(value);
        }
    }
}

Version data entries

104 entries across 104 versions & 1 rubygems

Version Path
embulk-0.8.39 embulk-core/src/main/java/org/embulk/spi/time/TimestampSerDe.java
embulk-0.8.39-java embulk-core/src/main/java/org/embulk/spi/time/TimestampSerDe.java
embulk-0.8.38 embulk-core/src/main/java/org/embulk/spi/time/TimestampSerDe.java
embulk-0.8.38-java embulk-core/src/main/java/org/embulk/spi/time/TimestampSerDe.java
embulk-0.8.37 embulk-core/src/main/java/org/embulk/spi/time/TimestampSerDe.java
embulk-0.8.37-java embulk-core/src/main/java/org/embulk/spi/time/TimestampSerDe.java
embulk-0.8.36 embulk-core/src/main/java/org/embulk/spi/time/TimestampSerDe.java
embulk-0.8.36-java embulk-core/src/main/java/org/embulk/spi/time/TimestampSerDe.java
embulk-0.8.35 embulk-core/src/main/java/org/embulk/spi/time/TimestampSerDe.java
embulk-0.8.35-java embulk-core/src/main/java/org/embulk/spi/time/TimestampSerDe.java
embulk-0.8.34 embulk-core/src/main/java/org/embulk/spi/time/TimestampSerDe.java
embulk-0.8.34-java embulk-core/src/main/java/org/embulk/spi/time/TimestampSerDe.java
embulk-0.8.33 embulk-core/src/main/java/org/embulk/spi/time/TimestampSerDe.java
embulk-0.8.33-java embulk-core/src/main/java/org/embulk/spi/time/TimestampSerDe.java
embulk-0.8.32 embulk-core/src/main/java/org/embulk/spi/time/TimestampSerDe.java
embulk-0.8.32-java embulk-core/src/main/java/org/embulk/spi/time/TimestampSerDe.java
embulk-0.8.31 embulk-core/src/main/java/org/embulk/spi/time/TimestampSerDe.java
embulk-0.8.31-java embulk-core/src/main/java/org/embulk/spi/time/TimestampSerDe.java
embulk-0.8.30 embulk-core/src/main/java/org/embulk/spi/time/TimestampSerDe.java
embulk-0.8.30-java embulk-core/src/main/java/org/embulk/spi/time/TimestampSerDe.java