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

com.github.marceloleite2604.util.time.duration.serializer.DurationToIso8601FormatSerializer Maven / Gradle / Ivy

There is a newer version: 1.0.1
Show newest version
package com.github.marceloleite2604.util.time.duration.serializer;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import java.io.IOException;
import java.time.Duration;

/**
 * 

* A {@link StdSerializer} extension to serialize {@link Duration} objects to a ISO-8601 formatted * text. *

*

* Its deserialization equivalent can be found on {@link DurationFromIso8601FormatDeserializer} * class. *

* * @author MarceloLeite2604 * */ public class DurationToIso8601FormatSerializer extends StdSerializer { private static final long serialVersionUID = 1L; public DurationToIso8601FormatSerializer() { super(Duration.class); } @Override public void serialize(Duration duration, JsonGenerator jsonGenerator, SerializerProvider serializer) throws IOException { jsonGenerator.writeString(duration.toString()); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy