Fix duration to microseconds conversion

See gh-27149
pull/27348/head
marckchr 3 years ago committed by Stephane Nicoll
parent 877f618a69
commit a406a46fa1

@ -183,7 +183,7 @@ public enum DurationStyle {
/**
* Microseconds.
*/
MICROS(ChronoUnit.MICROS, "us", (duration) -> duration.toMillis() * 1000L),
MICROS(ChronoUnit.MICROS, "us", duration -> duration.toNanos() / 1000L),
/**
* Milliseconds.

@ -234,6 +234,7 @@ class DurationStyleTests {
void printSimpleWithUnitShouldPrintInUnit() {
Duration duration = Duration.ofMillis(1000);
assertThat(DurationStyle.SIMPLE.print(duration, ChronoUnit.SECONDS)).isEqualTo("1s");
assertThat(DurationStyle.SIMPLE.print(Duration.ofNanos(2000), ChronoUnit.MICROS)).isEqualTo("2us");
}
}

Loading…
Cancel
Save