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

io.dropwizard.jersey.jsr310.InstantSecondParam Maven / Gradle / Ivy

package io.dropwizard.jersey.jsr310;

import io.dropwizard.jersey.params.AbstractParam;
import org.checkerframework.checker.nullness.qual.Nullable;

import java.time.Instant;

/**
 * A parameter encapsulating instant values in seconds. All non-parsable values
 * will return a {@code 400 Bad Request} response.
 *
 * @see Instant
 */
public class InstantSecondParam extends AbstractParam {
    public InstantSecondParam(@Nullable final String input) {
        super(input);
    }

    @Override
    protected Instant parse(@Nullable final String input) throws Exception {
        return Instant.ofEpochSecond(Long.parseLong(input));
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy