diff -r b42eaca7d234 -r 43eee1237934 src/jdk.jfr/share/classes/jdk/jfr/internal/tool/PrettyWriter.java --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/tool/PrettyWriter.java Thu Nov 28 13:02:30 2019 +0000 +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/tool/PrettyWriter.java Thu Nov 28 18:30:18 2019 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -57,9 +57,6 @@ * This class is also used by {@link RecordedObject#toString()} */ public final class PrettyWriter extends EventPrintWriter { - private static final Duration MILLSECOND = Duration.ofMillis(1); - private static final Duration SECOND = Duration.ofSeconds(1); - private static final Duration MINUTE = Duration.ofMinutes(1); private static final String TYPE_OLD_OBJECT = Type.TYPES_PREFIX + "OldObject"; private final static DateTimeFormatter TIME_FORMAT = DateTimeFormatter.ofPattern("HH:mm:ss.SSS"); private final static Long ZERO = 0L; @@ -553,15 +550,7 @@ println("N/A"); return true; } - if(d.compareTo(MILLSECOND) < 0){ - println(String.format("%.3f us", (double)d.toNanos() / 1_000)); - } else if(d.compareTo(SECOND) < 0){ - println(String.format("%.3f ms", (double)d.toNanos() / 1_000_000)); - } else if(d.compareTo(MINUTE) < 0){ - println(String.format("%.3f s", (double)d.toMillis() / 1_000)); - } else { - println(String.format("%d s", d.toSeconds())); - } + println(Utils.formatDuration(d)); return true; } if (value instanceof OffsetDateTime) {