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

com.fasterxml.jackson.jr.extension.javatime.LocalDateTimeValueReader Maven / Gradle / Ivy

Go to download

Jackson-jr extension that adds support for Java 8 Date/Time value types such as `java.time.LocalDateTime`

There is a newer version: 2.18.2
Show newest version
package com.fasterxml.jackson.jr.extension.javatime;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.jr.ob.api.ValueReader;
import com.fasterxml.jackson.jr.ob.impl.JSONReader;

import java.io.IOException;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class LocalDateTimeValueReader extends ValueReader {
    private final DateTimeFormatter formatter;

    public LocalDateTimeValueReader(DateTimeFormatter formatter) {
        super(LocalDateTime.class);
        this.formatter = formatter;
    }

    @Override
    public Object read(JSONReader reader, JsonParser p) throws IOException {
        return LocalDateTime.parse(p.getText(), formatter);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy