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

com.dslplatform.json.parsers.JsInstantParser Maven / Gradle / Ivy

package com.dslplatform.json.parsers;

import com.dslplatform.json.JsonReader;
import jsonvalues.JsInstant;
import jsonvalues.spec.Error;
import java.io.IOException;
import java.time.Instant;
import java.time.format.DateTimeParseException;
import java.util.Optional;
import java.util.function.Function;

import static java.time.format.DateTimeFormatter.ISO_INSTANT;

final class JsInstantParser extends AbstractParser {
    @Override
    JsInstant value(final JsonReader reader) throws JsParserException {
        try {
            return JsInstant.of(Instant.from(ISO_INSTANT.parse(reader.readString())));
        } catch (IOException | DateTimeParseException e) {
            throw new JsParserException(e.getMessage());
        }

    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy