@NotThreadSafe public final class SizeHelper extends Object
DecimalFormat class is not
thread-safe!| Modifier and Type | Field and Description |
|---|---|
static String |
B_SUFFIX
Suffix for Bytes
|
static String |
GB_SUFFIX
Suffix for Gigabytes
|
static String |
KB_SUFFIX
Suffix for Kilobytes
|
static String |
MB_SUFFIX
Suffix for Megabytes
|
static String |
PB_SUFFIX
Suffix for Petabytes
|
static String |
TB_SUFFIX
Suffix for Terabytes
|
| Constructor and Description |
|---|
SizeHelper(DecimalFormatSymbols aDFS) |
SizeHelper(Locale aDisplayLocale) |
| Modifier and Type | Method and Description |
|---|---|
String |
getAsGB(long nSize) |
String |
getAsGB(long nSize,
int nDecimals) |
String |
getAsKB(long nSize) |
String |
getAsKB(long nSize,
int nDecimals) |
String |
getAsMatching(BigDecimal aSize)
Get the best matching formatting of the passed value.
|
String |
getAsMatching(BigDecimal aSize,
int nDecimals)
Get the best matching formatting of the passed value.
|
String |
getAsMatching(BigInteger aSize)
Get the best matching formatting of the passed value.
|
String |
getAsMatching(BigInteger aSize,
int nDecimals)
Get the best matching formatting of the passed value.
|
String |
getAsMatching(long nSize) |
String |
getAsMatching(long nSize,
int nDecimals) |
String |
getAsMB(long nSize) |
String |
getAsMB(long nSize,
int nDecimals) |
String |
getAsPB(long nSize) |
String |
getAsPB(long nSize,
int nDecimals) |
String |
getAsTB(long nSize) |
String |
getAsTB(long nSize,
int nDecimals) |
static SizeHelper |
getSizeHelperOfLocale(Locale aDisplayLocale)
Get the size helper for the passed locale.
|
String |
toString() |
public static final String B_SUFFIX
public static final String KB_SUFFIX
public static final String MB_SUFFIX
public static final String GB_SUFFIX
public static final String TB_SUFFIX
public static final String PB_SUFFIX
public SizeHelper(@Nonnull DecimalFormatSymbols aDFS)
@Nonnull public String getAsKB(long nSize, @Nonnegative int nDecimals)
@Nonnull public String getAsMB(long nSize, @Nonnegative int nDecimals)
@Nonnull public String getAsGB(long nSize, @Nonnegative int nDecimals)
@Nonnull public String getAsTB(long nSize, @Nonnegative int nDecimals)
@Nonnull public String getAsPB(long nSize, @Nonnegative int nDecimals)
@Nonnull public String getAsMatching(@Nonnull BigInteger aSize)
aSize - The value to be converted to a size value. May not be
null.IllegalArgumentException - If the passed value cannot be fit in a long@Nonnull public String getAsMatching(@Nonnull BigInteger aSize, @Nonnegative int nDecimals)
aSize - The value to be converted to a size value. May not be
null.nDecimals - The number of fraction digits.IllegalArgumentException - If the passed value cannot be fit in a long@Nonnull public String getAsMatching(@Nonnull BigDecimal aSize)
aSize - The value to be converted to a size value. May not be
null.IllegalArgumentException - If the passed value cannot be fit in a long@Nonnull public String getAsMatching(@Nonnull BigDecimal aSize, @Nonnegative int nDecimals)
aSize - The value to be converted to a size value. May not be
null.nDecimals - The number of fraction digits.IllegalArgumentException - If the passed value cannot be fit in a long@Nonnull public String getAsMatching(long nSize, @Nonnegative int nDecimals)
@Nonnull public static SizeHelper getSizeHelperOfLocale(@Nonnull Locale aDisplayLocale)
aDisplayLocale - The locale to be used.null SizeHelper object for the passed
locale.Copyright © 2014–2019 Philip Helger. All rights reserved.