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

net.nemerosa.ontrack.json.JDKYearMonthDeserializer Maven / Gradle / Ivy

There is a newer version: 4.4.5
Show newest version
package net.nemerosa.ontrack.json;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonNode;

import java.io.IOException;
import java.time.YearMonth;

public class JDKYearMonthDeserializer extends JsonDeserializer {
    @Override
    public YearMonth deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
        JsonNode node = jp.readValueAsTree();
        int year = node.path("year").asInt();
        int month = node.path("month").asInt();
        return YearMonth.of(year, month);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy