Package net.sf.jasperreports.engine.util
Class FormatUtils
java.lang.Object
net.sf.jasperreports.engine.util.FormatUtils
- Author:
- Narcis Marcu (narcism@users.sourceforge.net)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic DategetFormattedDate(DateFormat dateFormat, String fieldValue, Class<?> valueClass) Creates a date from a string valuestatic NumbergetFormattedNumber(NumberFormat numberFormat, String fieldValue, Class<?> valueClass) Creates a number from a string valuegetIcu4jNumberFormat(String pattern, Locale locale) Returns an ICU4j NumberFormat instance if ICU4j is available and the pattern has variable grouping.
-
Constructor Details
-
FormatUtils
public FormatUtils()
-
-
Method Details
-
getFormattedNumber
public static Number getFormattedNumber(NumberFormat numberFormat, String fieldValue, Class<?> valueClass) throws ParseException Creates a number from a string value- Parameters:
numberFormat-fieldValue-valueClass-- Returns:
- the number as parsed from the string
- Throws:
ParseException
-
getFormattedDate
public static Date getFormattedDate(DateFormat dateFormat, String fieldValue, Class<?> valueClass) throws ParseException Creates a date from a string value- Parameters:
dateFormat-fieldValue-valueClass-- Returns:
- the date as parsed from the string
- Throws:
ParseException
-
getIcu4jNumberFormat
Returns an ICU4j NumberFormat instance if ICU4j is available and the pattern has variable grouping. If ICU4j is not available or the pattern does not have variable grouping, returns an empty Optional.- Parameters:
pattern- the number format patternlocale- the locale for the number format- Returns:
- an Optional containing the ICU4j NumberFormat if available and applicable, otherwise empty
-