Created
November 9, 2023 20:52
-
-
Save cwensel/cdadcfba84fb039e9504709d4c5de733 to your computer and use it in GitHub Desktop.
Uses mini-parsers-temporal library to add duration strings to config files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import heretical.parser.temporal.DurationParser; | |
import org.eclipse.microprofile.config.spi.Converter; | |
import java.time.Duration; | |
/** | |
* Uses <a href="https://github.com/Heretical/mini-parsers">Mini-Parsers</a> to parse a duration string | |
* in a config file. | |
*/ | |
public class DurationConverter implements Converter<Duration> { | |
DurationParser parser = new DurationParser(); | |
@Override | |
public Duration convert(String value) throws IllegalArgumentException, NullPointerException { | |
return parser.parse(value).getResult(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment