Package org.thymeleaf.util
Class NumberUtils
java.lang.Object
org.thymeleaf.util.NumberUtils
- Since:
- 1.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static DecimalFormatSymbolscomputeDecimalFormatSymbols(NumberPointType decimalPointType, NumberPointType thousandsPointType, Locale locale) static Stringstatic Stringformat(Number target, Integer minIntegerDigits, Integer decimalDigits, NumberPointType decimalPointType, Locale locale) static Stringstatic Stringformat(Number target, Integer minIntegerDigits, NumberPointType thousandsPointType, Integer decimalDigits, Locale locale) static Stringformat(Number target, Integer minIntegerDigits, NumberPointType thousandsPointType, Integer decimalDigits, NumberPointType decimalPointType, Locale locale) static Stringformat(Number target, Integer minIntegerDigits, NumberPointType thousandsPointType, Locale locale) static StringformatCurrency(Number target, Locale locale) Formats a number as a currency value according to the specified locale.private static StringformatNumber(Number target, Integer minIntegerDigits, NumberPointType thousandsPointType, Integer fractionDigits, NumberPointType decimalPointType, Locale locale) Formats a number as per the given values.static StringformatPercent(Number target, Integer minIntegerDigits, Integer fractionDigits, Locale locale) Formats a number as a percentage value.static Integer[]Produces an array with a sequence of integer numbers.static Integer[]Produces an array with a sequence of integer numbers, using a step.
-
Constructor Details
-
NumberUtils
private NumberUtils()
-
-
Method Details
-
format
-
format
public static String format(Number target, Integer minIntegerDigits, NumberPointType thousandsPointType, Locale locale) -
format
-
format
-
format
-
format
public static String format(Number target, Integer minIntegerDigits, NumberPointType thousandsPointType, Integer decimalDigits, NumberPointType decimalPointType, Locale locale) -
sequence
Produces an array with a sequence of integer numbers.
- Parameters:
from- value to start the sequence fromto- value to produce the sequence to- Returns:
- the Integer[] sequence
- Since:
- 1.1.2
-
sequence
Produces an array with a sequence of integer numbers, using a step.
- Parameters:
from- value to start the sequence fromto- value to produce the sequence tostep- the step to be used- Returns:
- the Integer[] sequence
- Since:
- 2.0.9
-
formatNumber
private static String formatNumber(Number target, Integer minIntegerDigits, NumberPointType thousandsPointType, Integer fractionDigits, NumberPointType decimalPointType, Locale locale) Formats a number as per the given values.- Parameters:
target- The number to format.minIntegerDigits- Minimum number digits to return (0 padding).thousandsPointType- Character to use for separating number groups.fractionDigits- Minimum number of fraction digits to format to (0 padding).decimalPointType- Character to use for separating decimals.locale- Locale to draw more information from.- Returns:
- The number formatted as specified, or
nullif the number given isnull.
-
computeDecimalFormatSymbols
private static DecimalFormatSymbols computeDecimalFormatSymbols(NumberPointType decimalPointType, NumberPointType thousandsPointType, Locale locale) -
formatCurrency
Formats a number as a currency value according to the specified locale.- Parameters:
target- The number to format.locale- Locale to use for formatting.- Returns:
- The number formatted as a currency, or
nullif the number given isnull.
-
formatPercent
public static String formatPercent(Number target, Integer minIntegerDigits, Integer fractionDigits, Locale locale) Formats a number as a percentage value.- Parameters:
target- The number to format.minIntegerDigits- Minimum number of digits to return (0 padding).fractionDigits- Minimum number of fraction digits to return (0 padding).locale- Locale to use for formatting.- Returns:
- The number formatted as a percentage, or
nullif the number given isnull.
-