public class UnitFormatter extends Object
UnitSystem. For example
13504653 can be formatted as 13,5 MB", "12.9 MiB", "13MB 504KB 653B" "or "14MW". The highest unit prefix
is giga (e.g. "G" or "Gi", the lowest prefix is the one from the base (typically empty)| Constructor and Description |
|---|
UnitFormatter() |
| Modifier and Type | Method and Description |
|---|---|
static String |
formatAsUnit(long value,
UnitSystem unitSystem,
String unitPostfix)
Formats a value to human readable representation, using the given Unit System.
|
static String |
formatAsUnit(long value,
UnitSystem unitSystem,
String unitPostfix,
DecimalFormat format)
Formats a value to human readable representation, using the given Unit System.
|
static String |
formatAsUnits(long number,
UnitSystem unitSystem,
String unitPostfix,
String separator)
Formats the value to human readable representation, using the given Unit System.
|
public static String formatAsUnit(long value, UnitSystem unitSystem, String unitPostfix)
formatAsUnit(long, UnitSystem, String, DecimalFormat).value - The number to formatunitSystem - The Unit systemunitPostfix - The postfix, for example "B" for byte or "W" for Watt. May be empty.public static String formatAsUnit(long value, UnitSystem unitSystem, String unitPostfix, DecimalFormat format)
value - The number to formatunitSystem - The Unit systemunitPostfix - The postfix, for example "B" for byte or "W" for Watt. May be empty.format - The decimal format for formatting the numberpublic static String formatAsUnits(long number, UnitSystem unitSystem, String unitPostfix, String separator)
number - The number to formatunitSystem - The Unit systemunitPostfix - The postfix, for example "B" for byte or "W" for Watt. May be empty.separator - The separator between the elementsCopyright © 2018 trivago. All rights reserved.