public class StringToLongConverter extends AbstractStringToNumberConverter<Long>
String to Long and back. Uses
the given locale and a NumberFormat instance for formatting and
parsing.
Override and overwrite getFormat(Locale) to use a different format.
| Constructor and Description |
|---|
StringToLongConverter(ErrorMessageProvider errorMessageProvider)
Creates a new converter instance with the given error message provider.
|
StringToLongConverter(Long emptyValue,
ErrorMessageProvider errorMessageProvider)
Creates a new converter instance with the given presentation value for
empty string and error message provider.
|
StringToLongConverter(Long emptyValue,
String errorMessage)
Creates a new converter instance with the given presentation value for
empty string and error message.
|
StringToLongConverter(String errorMessage)
Creates a new converter instance with the given error message.
|
| Modifier and Type | Method and Description |
|---|---|
Result<Long> |
convertToModel(String value,
ValueContext context)
Converts the given value from presentation type to model type.
|
protected NumberFormat |
getFormat(Locale locale)
Returns the format used by
Converter.convertToPresentation(Object, ValueContext) and
convertToModel(String, ValueContext). |
convertToNumber, convertToPresentation, getErrorMessagepublic StringToLongConverter(String errorMessage)
null.errorMessage - the error message to use if conversion failspublic StringToLongConverter(Long emptyValue, String errorMessage)
emptyValue - the presentation value to return when converting an empty
string, may be nullerrorMessage - the error message to use if conversion failspublic StringToLongConverter(ErrorMessageProvider errorMessageProvider)
null.errorMessageProvider - the error message provider to use if conversion failspublic StringToLongConverter(Long emptyValue, ErrorMessageProvider errorMessageProvider)
emptyValue - the presentation value to return when converting an empty
string, may be nullerrorMessageProvider - the error message provider to use if conversion failsprotected NumberFormat getFormat(Locale locale)
Converter.convertToPresentation(Object, ValueContext) and
convertToModel(String, ValueContext).getFormat in class AbstractStringToNumberConverter<Long>locale - The locale to usepublic Result<Long> convertToModel(String value, ValueContext context)
ConverterA converter can optionally use locale to do the conversion.
value - The value to convert. Can be nullcontext - The value context for the conversion.Copyright © 2025. All rights reserved.