Skip to content

Commit a4b4562

Browse files
committed
fix: Ensure same locale
1 parent 17e12a4 commit a4b4562

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/main/java/string/FormatBytesSnippet.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
*/
2424

2525
package string;
26+
27+
import java.util.Locale;
2628

2729
/**
2830
* FormatBytesSnippet.
@@ -44,13 +46,13 @@ public static String formatBytes(long bytes) {
4446
if ((bytes >= 0) && (bytes < kb)) {
4547
return bytes + " B";
4648
} else if ((bytes >= kb) && (bytes < mb)) {
47-
return String.format("%.2f KB", bytes / kb);
49+
return String.format(Locale.ENGLISH, "%.2f KB", bytes / kb);
4850
} else if ((bytes >= mb) && (bytes < gb)) {
49-
return String.format("%.2f MB", bytes / mb);
51+
return String.format(Locale.ENGLISH, "%.2f MB", bytes / mb);
5052
} else if ((bytes >= gb) && (bytes < tb)) {
51-
return String.format("%.2f GB", bytes / gb);
53+
return String.format(Locale.ENGLISH, "%.2f GB", bytes / gb);
5254
} else if (bytes >= tb) {
53-
return String.format("%.2f TB", bytes / tb);
55+
return String.format(Locale.ENGLISH, "%.2f TB", bytes / tb);
5456
} else {
5557
return "Invalid Input";
5658
}

0 commit comments

Comments
 (0)