Converters
Converters are used in mappers to convert types. They are auto-configured as Spring beans and can be customized via application.properties.
|
Property |
Default |
Description |
|---|---|---|
|
|
|
If |
Available Converters
DateToString
Converts date to string.
|
Option |
Type |
Property |
Default |
Description |
|---|---|---|---|---|
|
|
String |
|
|
Value if input is missing |
|
|
String |
|
|
Output format (SimpleDateFormat) |
|
|
String |
|
|
Input format if input is stringified date |
|
|
String |
|
|
What counts as null input |
StringToDate
Converts string to LocalDate.
|
Option |
Type |
Property |
Default |
Description |
|---|---|---|---|---|
|
|
LocalDate |
|
|
Value if input is missing |
|
|
String |
|
|
Input format |
Usage in mapper: stringToDate() or stringToDate(yyyy/MM/dd)
StringToDateTime
Converts string to DateTime.
|
Option |
Type |
Property |
Default |
Description |
|---|---|---|---|---|
|
|
DateTime |
|
|
Value if input is missing |
|
|
String |
|
|
Input format |
|
|
DateTimeZone |
|
|
Input timezone |
|
|
DateTimeZone |
|
|
Output timezone |
Usage in mapper: stringToDateTime() or stringToDateTime(yyyy/MM/dd'T'HH:mm:ss)
StringToNumber
Converts string to BigInteger.
|
Option |
Type |
Property |
Default |
Description |
|---|---|---|---|---|
|
|
BigInteger |
|
|
Value if input is missing |
Usage in mapper: stringToNumber or stringToNumber() or stringToNumber(5)
StringToInteger
Converts string to Integer.
|
Option |
Type |
Property |
Default |
Description |
|---|---|---|---|---|
|
|
Integer |
|
|
Value if input is missing |
|
|
String |
|
|
Decimal/thousands separator locale |
Usage in mapper: stringToInteger, stringToInteger(), stringToInteger(5), stringToInteger(locale), stringToInteger(locale,defaultValue)
StringToDecimal
Converts string to BigDecimal.
|
Option |
Type |
Property |
Default |
Description |
|---|---|---|---|---|
|
|
BigDecimal |
|
|
Value if input is missing |
|
|
String |
|
|
Decimal/thousands separator locale |
|
|
RoundingMode |
N/A |
|
Rounding behavior |
|
|
Integer |
N/A |
|
Number of digits in unscaled value |
Usage in mapper: stringToDecimal, stringToDecimal(2), stringToDecimal(de), stringToDecimal(de,2)
StringToDouble
Converts string to Double.
|
Option |
Type |
Property |
Default |
Description |
|---|---|---|---|---|
|
|
Double |
|
|
Value if input is missing |
Usage in mapper: stringToDouble, stringToDouble(), stringToDouble(5)
EmptyStringToNull
Converts empty string to null. No configuration options.
NullToDefault
Returns default value when input matches null value.
|
Option |
Type |
Property |
Default |
Description |
|---|---|---|---|---|
|
|
Object |
|
|
What counts as null |
|
|
Object |
|
|
Value to return |
Usage in mapper: nullToDefault, nullToDefault(0), nullToDefault(,0) (empty nullValue, default 0)
StringRight
Returns rightmost N characters.
|
Option |
Type |
Property |
Default |
Description |
|---|---|---|---|---|
|
|
Integer |
|
|
Length from right |
Usage in mapper: stringRight(2)
StringLeft
Returns leftmost N characters.
|
Option |
Type |
Property |
Default |
Description |
|---|---|---|---|---|
|
|
Integer |
|
|
Length from left |
Usage in mapper: stringLeft(2)
DateTimeToString
Converts DateTime to string.
|
Option |
Type |
Property |
Default |
Description |
|---|---|---|---|---|
|
|
String |
|
|
Value if input is missing |
|
|
String |
|
|
Output format |
|
|
DateTimeZone |
|
|
Output timezone |
DecimalToString
Converts BigDecimal to string.
|
Option |
Type |
Property |
Default |
Description |
|---|---|---|---|---|
|
|
String |
|
|
Value if input is missing |
|
|
NumberFormat |
|
|
Number format |
|
|
Locale |
|
server locale |
Decimal/thousands separator |
|
|
String |
|
|
Display pattern for zeros, prefixes, grouping |
Quick Reference
|
Converter |
Bean Name |
Input |
Output |
Mapper Expression |
|---|---|---|---|---|
|
DateToString |
|
Date |
String |
N/A |
|
StringToDate |
|
String |
LocalDate |
|
|
StringToDateTime |
|
String |
DateTime |
|
|
StringToNumber |
|
String |
BigInteger |
|
|
StringToInteger |
|
String |
Integer |
|
|
StringToDecimal |
|
String |
BigDecimal |
|
|
StringToDouble |
|
String |
Double |
|
|
EmptyStringToNull |
|
String |
null |
N/A |
|
NullToDefault |
|
Object |
Object |
|
|
StringRight |
|
String |
String |
|
|
StringLeft |
|
String |
String |
|
|
DateTimeToString |
|
DateTime |
String |
N/A |
|
DecimalToString |
|
BigDecimal |
String |
N/A |
Common Pitfalls
-
Locale-sensitive parsing --
StringToDecimalandStringToIntegeruse the server's default locale if none is specified. German locale uses comma as decimal separator (1.234,56), while US locale uses period (1,234.56). -
Date format mismatch -- Ensure the
formatpattern matches your input data exactly. A mismatch causes silent failures or parse exceptions. -
Converter chaining -- Converters cannot be chained in a single mapper field. Use a Groovy expression for multi-step conversions.