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

nl.vpro.rs.converters.DurationParamConverter Maven / Gradle / Ivy

There is a newer version: 5.3.3
Show newest version
package nl.vpro.rs.converters;

import java.time.Duration;

import jakarta.ws.rs.ext.ParamConverter;

import nl.vpro.util.TimeUtils;


/**
 * @author Michiel Meeuwissen
 * @since 0.28
 */

public class DurationParamConverter implements ParamConverter {

    public static final DurationParamConverter INSTANCE = new DurationParamConverter();

    @Override
    public Duration fromString(String value) {
        return TimeUtils.parseDuration(value).orElse(null);
    }

    @Override
    public String toString(Duration value) {
        if (value == null) {
           return null;
        }
        return value.toString();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy