Class ConvertUtils
Utility methods for converting String scalar values to objects of the specified Class, String arrays to arrays of the specified Class.
 For more details, see ConvertUtilsBean which provides the implementations for these methods.
 
- See Also:
- 
Method SummaryModifier and TypeMethodDescriptionstatic StringConverts the specified value into a String.static ObjectConverts the value to an object of the specified class (if possible).static ObjectConvert an array of specified values to an array of objects of the specified class (if possible).static ObjectConverts the specified value to an object of the specified class (if possible).static voidRemove all registeredConverters, and re-establish the standard Converters.static voidderegister(Class<?> clazz) Remove any registeredConverterfor the specified destinationClass.static <T> Converter<T> Look up and return any registeredConverterfor the specified source and destination class; if there is no registered Converter, returnnull.static <T> Converter<T> Look up and return any registeredConverterfor the specified destination class; if there is no registered Converter, returnnull.static <T> Class<T> primitiveToWrapper(Class<T> type) Change primitive Class types to the associated wrapper class.static <T> voidRegister a customConverterfor the specified destinationClass, replacing any previously registered Converter.
- 
Method Details- 
convertConverts the specified value into a String. For more details see ConvertUtilsBean.- Parameters:
- value- Value to be converted (may be null)
- Returns:
- The converted String value or null if value is null
- See Also:
 
- 
convertConverts the value to an object of the specified class (if possible). - Parameters:
- value- Value to be converted (may be null)
- targetType- Class of the value to be converted to (must not be null)
- Returns:
- The converted value
- Throws:
- ConversionException- if thrown by an underlying Converter
 
- 
convertConverts the specified value to an object of the specified class (if possible). Otherwise, return a String representation of the value. For more details see ConvertUtilsBean.- Parameters:
- value- Value to be converted (may be null)
- clazz- Java class to be converted to (must not be null)
- Returns:
- The converted value
- See Also:
 
- 
convertConvert an array of specified values to an array of objects of the specified class (if possible). For more details see ConvertUtilsBean.- Parameters:
- values- Array of values to be converted
- clazz- Java array or element class to be converted to (must not be null)
- Returns:
- The converted value
- See Also:
 
- 
deregisterRemove all registered Converters, and re-establish the standard Converters.For more details see ConvertUtilsBean.- See Also:
 
- 
deregisterRemove any registered Converterfor the specified destinationClass.For more details see ConvertUtilsBean.- Parameters:
- clazz- Class for which to remove a registered Converter
- See Also:
 
- 
lookupLook up and return any registeredConverterfor the specified source and destination class; if there is no registered Converter, returnnull.- Type Parameters:
- T- The converter type.
- Parameters:
- sourceType- Class of the value being converted
- targetType- Class of the value to be converted to
- Returns:
- The registered Converterornullif not found
 
- 
lookupLook up and return any registered Converterfor the specified destination class; if there is no registered Converter, returnnull.For more details see ConvertUtilsBean.- Type Parameters:
- T- The converter type.
- Parameters:
- clazz- Class for which to return a registered Converter
- Returns:
- The registered Converterornullif not found
- See Also:
 
- 
primitiveToWrapperChange primitive Class types to the associated wrapper class. This is useful for concrete converter implementations which typically treat primitive types like their corresponding wrapper types.- Type Parameters:
- T- The type to be checked.
- Parameters:
- type- The class type to check.
- Returns:
- The converted type.
- Since:
- 1.9
 
- 
registerRegister a custom Converterfor the specified destinationClass, replacing any previously registered Converter.For more details see ConvertUtilsBean.- Type Parameters:
- T- The converter type.
- Parameters:
- converter- Converter to be registered
- clazz- Destination class for conversions performed by this Converter
- See Also:
 
 
-