mirror of
https://github.com/openjdk/jdk.git
synced 2026-04-21 12:20:29 +00:00
8316454: JFR break locale settings
Reviewed-by: mgronlun
This commit is contained in:
parent
c42535f111
commit
de95259306
@ -57,7 +57,6 @@ public final class ValueFormatter {
|
||||
}
|
||||
}
|
||||
|
||||
private static final NumberFormat NUMBER_FORMAT = NumberFormat.getNumberInstance();
|
||||
private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter.ofPattern("HH:mm:ss");
|
||||
private static final Duration MICRO_SECOND = Duration.ofNanos(1_000);
|
||||
private static final Duration SECOND = Duration.ofSeconds(1);
|
||||
@ -69,6 +68,12 @@ public final class ValueFormatter {
|
||||
private static final int DISPLAY_NANO_DIGIT = 3;
|
||||
private static final int BASE = 10;
|
||||
|
||||
// -XX:FlightRecorderOptions:repository=<path> triggers an upcall
|
||||
// which will load this class. If NumberFormat.getNumberInstance()
|
||||
// is called during startup, locale settings will not take effect.
|
||||
// Workaround is to create an instance lazily. See numberFormatInstance().
|
||||
private static NumberFormat NUMBER_FORMAT;
|
||||
|
||||
public static String formatTimespan(Duration dValue, String separation) {
|
||||
if (dValue == null) {
|
||||
return "0";
|
||||
@ -110,8 +115,15 @@ public final class ValueFormatter {
|
||||
}
|
||||
}
|
||||
|
||||
private static NumberFormat numberFormatInstance() {
|
||||
if (NUMBER_FORMAT == null) {
|
||||
NUMBER_FORMAT = NumberFormat.getNumberInstance();
|
||||
}
|
||||
return NUMBER_FORMAT;
|
||||
}
|
||||
|
||||
public static String formatNumber(Number n) {
|
||||
return NUMBER_FORMAT.format(n);
|
||||
return numberFormatInstance().format(n);
|
||||
}
|
||||
|
||||
public static String formatDuration(Duration d) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user