Skip to content

Commit 6c18d13

Browse files
committed
UnitUtils: don't force US Locale
The purpose of the UnitUtils is to return back a String for a given number of bytes in the format of the user's Locale. Added javadoc clarifying this
1 parent f5708d5 commit 6c18d13

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/main/java/org/scijava/util/UnitUtils.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131

3232
package org.scijava.util;
3333

34-
import java.util.Locale;
3534

3635
/**
3736
* Utility methods for working with units.
@@ -50,6 +49,10 @@ private UnitUtils() {
5049
// prevent instantiation of utility class
5150
}
5251

52+
/**
53+
* @return A properly formatted String representation of the given bytes, in
54+
* the default {@link java.util.Locale} for this JVM.
55+
*/
5356
public static String getAbbreviatedByteLabel(final double totBytes) {
5457
if (totBytes < 0) {
5558
throw new IllegalArgumentException("Bytes must be non-negative");
@@ -65,7 +68,7 @@ public static String getAbbreviatedByteLabel(final double totBytes) {
6568

6669
// format result with 0 decimal places for bytes, or 1 for larger values
6770
final String format = pow == 0 ? "%.0f%s" : "%.1f%s";
68-
return String.format(Locale.US, format, value, BYTE_UNITS[pow]);
71+
return String.format(format, value, BYTE_UNITS[pow]);
6972
}
7073

7174
}

0 commit comments

Comments
 (0)