org.kiwiproject.dropwizard.util.KiwiDropwizardDurations Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kiwi Show documentation
Show all versions of kiwi Show documentation
Kiwi is a utility library. We really like Google's Guava, and also use Apache Commons.
But if they don't have something we need, and we think it is useful, this is where we put it.
package org.kiwiproject.dropwizard.util;
import lombok.experimental.UtilityClass;
import java.time.Duration;
/**
* Utility that maps Dropwizard {@link io.dropwizard.util.Duration} to Java {@link java.time.Duration}
*/
@UtilityClass
public class KiwiDropwizardDurations {
public static Duration fromDropwizardDuration(io.dropwizard.util.Duration duration) {
var javaDuration = Duration.ofMillis(duration.toMilliseconds());
if (javaDuration.isZero()) {
return Duration.ofNanos(duration.toNanoseconds());
}
return javaDuration;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy