public final class Formatter
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static java.lang.ThreadLocal<java.text.NumberFormat> |
cleanNumForm |
private static java.util.Locale |
locale |
private static java.lang.ThreadLocal<java.text.NumberFormat> |
numForm
use ThreadLocal to generate new formatter for each Thread since NumberFormat is not synchronized
|
Constructor and Description |
---|
Formatter() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
bytesToString(long byteCount)
Formats a number if it are bytes to greatest unit (1024 based)
|
private static java.lang.String |
number(double d) |
static java.lang.String |
number(double d,
boolean localized) |
static java.lang.String |
number(long l) |
static java.lang.String |
number(long l,
boolean localized) |
static java.lang.String |
number(java.lang.String s)
Method formats String representation of numbers according to the formatting
rules for numbers defined by this class.
|
private static void |
setLocale(java.util.Locale l) |
static void |
setLocale(java.lang.String lang) |
private static java.util.Locale locale
private static final java.lang.ThreadLocal<java.text.NumberFormat> numForm
private static final java.lang.ThreadLocal<java.text.NumberFormat> cleanNumForm
private static void setLocale(java.util.Locale l)
locale
- the Locale
to set or null
to set the special
empty locale to create unformatted numberspublic static void setLocale(java.lang.String lang)
lang
- an ISO 639 language code which is used to generate a Locale
public static java.lang.String number(double d, boolean localized)
private static java.lang.String number(double d)
public static java.lang.String number(long l, boolean localized)
public static java.lang.String number(long l)
public static java.lang.String number(java.lang.String s)
s
- string to parse into a number and reformatpublic static java.lang.String bytesToString(long byteCount)
byteCount
-