Package net.runelite.client.util
Class QuantityFormatter
- java.lang.Object
-
- net.runelite.client.util.QuantityFormatter
-
public class QuantityFormatter extends Object
A set of utility functions to use when formatting quantities
-
-
Constructor Summary
Constructors Constructor Description QuantityFormatter()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
formatNumber(double number)
Formats a number to be comma delimited.static String
formatNumber(long number)
Formats a number to be comma delimited.static long
parseQuantity(String string)
Converts a string representation of a stack back to (close to) it's original value.static String
quantityToRSDecimalStack(int quantity)
Convert a quantity to a short SI-prefix style string, possibly with a decimal, with K after 100,000 and M after 10,000,000 example:9,450
,2.1B
,100K
static String
quantityToRSDecimalStack(int quantity, boolean precise)
Convert a quantity to a short SI-prefix style string, possibly with decimals, with K after 100,000 and M after 10,000,000 example withoutprecise
:9,450
,2.1B
,8.4M
example withprecise
:9,450
,2.147B
,8.32M
static String
quantityToStackSize(long quantity)
Convert a quantity to a short, comma separated, SI-prefix style string example:9,450
,2.14B
,100K
-
-
-
Method Detail
-
quantityToStackSize
public static String quantityToStackSize(long quantity)
Convert a quantity to a short, comma separated, SI-prefix style string example:9,450
,2.14B
,100K
- Parameters:
quantity
- The quantity to convert.- Returns:
- a 6 or less character string, possibly with a decimal point, commas or K/M/B suffix
-
quantityToRSDecimalStack
public static String quantityToRSDecimalStack(int quantity)
Convert a quantity to a short SI-prefix style string, possibly with a decimal, with K after 100,000 and M after 10,000,000 example:9,450
,2.1B
,100K
- See Also:
quantityToRSDecimalStack(int, boolean)
-
quantityToRSDecimalStack
public static String quantityToRSDecimalStack(int quantity, boolean precise)
Convert a quantity to a short SI-prefix style string, possibly with decimals, with K after 100,000 and M after 10,000,000 example withoutprecise
:9,450
,2.1B
,8.4M
example withprecise
:9,450
,2.147B
,8.32M
- Parameters:
precise
- If true, allow thousandths precision ifquantity
is larger than 1 million. Otherwise have at most a single decimal
-
parseQuantity
public static long parseQuantity(String string) throws ParseException
Converts a string representation of a stack back to (close to) it's original value.- Parameters:
string
- The string to convert.- Returns:
- A long representation of it.
- Throws:
ParseException
-
formatNumber
public static String formatNumber(long number)
Formats a number to be comma delimited. No suffixes are given example:10,123,351
,5
-
formatNumber
public static String formatNumber(double number)
Formats a number to be comma delimited. No suffixes are given. Has at most 3 decimal places example:10,123,351
,5.612
-
-