public class SizeLongConverter extends Object implements LongConverter
LongConverter interface, providing methods to parse a string
with a size suffix back into a long value and to convert a long value
into its string representation with the appropriate size suffix.| Modifier and Type | Field and Description |
|---|---|
static SizeLongConverter |
INSTANCE
The singleton instance of this class.
|
| Constructor and Description |
|---|
SizeLongConverter() |
| Modifier and Type | Method and Description |
|---|---|
void |
append(StringBuilder text,
long value)
Converts a long value to its string representation, appending a size
suffix (K, M, G, T) if the value is a multiple of 1024 to a power
(kilo, mega, giga, tera, respectively).
|
long |
parse(CharSequence text)
Parses a string representation of a number with a size suffix
(K, M, G, T) and converts it into a long value.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddEncode, allSafeChars, allSafeChars, append, asString, asText, asText, forSymbols, lengthCheck, lengthCheck, maxParseLength, maxParseLength, parsepublic static final SizeLongConverter INSTANCE
public long parse(CharSequence text) throws NumberFormatException
parse in interface LongConvertertext - The text to parse, containing a numeric value followed by
a size suffix (K, M, G, T). Case-insensitive.NumberFormatException - If the text before the size suffix is not
a valid long number or if the text is empty.public void append(StringBuilder text, long value)
append in interface LongConvertertext - The StringBuilder to which the converted value
and suffix are appended.value - The long value to be converted.Copyright © 2024. All rights reserved.