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.19 embulk-core/src/main/java/org/embulk/spi/time/TimestampSerDe.java
embulk-0.8.19-java embulk-core/src/main/java/org/embulk/spi/time/TimestampSerDe.java
embulk-0.8.18 embulk-core/src/main/java/org/embulk/spi/time/TimestampSerDe.java
embulk-0.8.18-java embulk-core/src/main/java/org/embulk/spi/time/TimestampSerDe.java
embulk-0.8.17 embulk-core/src/main/java/org/embulk/spi/time/TimestampSerDe.java
embulk-0.8.17-java embulk-core/src/main/java/org/embulk/spi/time/TimestampSerDe.java
embulk-0.8.16 embulk-core/src/main/java/org/embulk/spi/time/TimestampSerDe.java
embulk-0.8.16-java embulk-core/src/main/java/org/embulk/spi/time/TimestampSerDe.java
embulk-0.8.15 embulk-core/src/main/java/org/embulk/spi/time/TimestampSerDe.java
embulk-0.8.15-java embulk-core/src/main/java/org/embulk/spi/time/TimestampSerDe.java
embulk-0.8.14 embulk-core/src/main/java/org/embulk/spi/time/TimestampSerDe.java
embulk-0.8.14-java embulk-core/src/main/java/org/embulk/spi/time/TimestampSerDe.java
embulk-0.8.13 embulk-core/src/main/java/org/embulk/spi/time/TimestampSerDe.java
embulk-0.8.13-java embulk-core/src/main/java/org/embulk/spi/time/TimestampSerDe.java
embulk-0.8.12 embulk-core/src/main/java/org/embulk/spi/time/TimestampSerDe.java
embulk-0.8.12-java embulk-core/src/main/java/org/embulk/spi/time/TimestampSerDe.java
embulk-0.8.11-java embulk-core/src/main/java/org/embulk/spi/time/TimestampSerDe.java
embulk-0.8.11 embulk-core/src/main/java/org/embulk/spi/time/TimestampSerDe.java
embulk-0.8.10 embulk-core/src/main/java/org/embulk/spi/time/TimestampSerDe.java
embulk-0.8.10-java embulk-core/src/main/java/org/embulk/spi/time/TimestampSerDe.java