Package org.apache.commons.beanutils2.locale

# Class LocaleConvertUtils

java.lang.Object
org.apache.commons.beanutils2.locale.LocaleConvertUtils

public final class LocaleConvertUtils extends Object

Utility methods for converting locale-sensitive String scalar values to objects of the specified Class, String arrays to arrays of the specified Class and object to locale-sensitive String scalar value.

The implementations for these method are provided by `LocaleConvertUtilsBean`. These static utility method use the default instance. More sophisticated can be provided by using a `LocaleConvertUtilsBean` instance.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static String`
  `convert(Object value)`
  Converts the specified locale-sensitive value into a String.
  `static String`
  `convert(Object value, String pattern)`
  Converts the specified locale-sensitive value into a String using the conversion pattern.
  `static String`
  `convert(Object value, Locale locale, String pattern)`
  Converts the specified locale-sensitive value into a String using the particular conversion pattern.
  `static Object`
  `convert(String[] values, Class<?> clazz)`
  Convert an array of specified values to an array of objects of the specified class (if possible).
  `static Object`
  `convert(String[] values, Class<?> clazz, String pattern)`
  Convert an array of specified values to an array of objects of the specified class (if possible) using the conversion pattern.
  `static Object`
  `convert(String[] values, Class<?> clazz, Locale locale, String pattern)`
  Convert an array of specified values to an array of objects of the specified class (if possible) using the conversion pattern.
  `static Object`
  `convert(String value, Class<?> clazz)`
  Converts the specified value to an object of the specified class (if possible).
  `static Object`
  `convert(String value, Class<?> clazz, String pattern)`
  Converts the specified value to an object of the specified class (if possible) using the conversion pattern.
  `static Object`
  `convert(String value, Class<?> clazz, Locale locale, String pattern)`
  Converts the specified value to an object of the specified class (if possible) using the conversion pattern.
  `static void`
  `deregister()`
  Remove any registered `LocaleConverter`.
  `static void`
  `deregister(Class<?> clazz, Locale locale)`
  Remove any registered `LocaleConverter` for the specified locale and Class.
  `static void`
  `deregister(Locale locale)`
  Remove any registered `LocaleConverter` for the specified locale.
  `static boolean`
  `getApplyLocalized()`
  Gets applyLocalized.
  `static Locale`
  `getDefaultLocale()`
  Gets the `Locale` which will be used when no `Locale` is passed to a method.
  `static <T> LocaleConverter<T>`
  `lookup(Class<T> clazz, Locale locale)`
  Look up and return any registered `LocaleConverter` for the specified destination class and locale; if there is no registered Converter, return `null`.
  `static <T> void`
  `register(LocaleConverter<T> converter, Class<T> clazz, Locale locale)`
  Register a custom `LocaleConverter` for the specified destination `Class`, replacing any previously registered converter.
  `static void`
  `setApplyLocalized(boolean newApplyLocalized)`
  Sets applyLocalized.
  `static void`
  `setDefaultLocale(Locale locale)`
  Sets the `Locale` which will be used when no `Locale` is passed to a method.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### convert

    public static String convert(Object value)

    Converts the specified locale-sensitive value into a String.

    For more details see `LocaleConvertUtilsBean`

    Parameters:
      `value` - The Value to be converted
    Returns:
      the converted value
    See Also:
      - `LocaleConvertUtilsBean.convert(Object)`

  - ### convert

    public static String convert(Object value, Locale locale, String pattern)

    Converts the specified locale-sensitive value into a String using the particular conversion pattern.

    For more details see `LocaleConvertUtilsBean`

    Parameters:
      `value` - The Value to be converted
      `locale` - The locale
      `pattern` - The conversion pattern
    Returns:
      the converted value
    See Also:
      - `LocaleConvertUtilsBean.convert(Object, Locale, String)`

  - ### convert

    public static String convert(Object value, String pattern)

    Converts the specified locale-sensitive value into a String using the conversion pattern.

    For more details see `LocaleConvertUtilsBean`

    Parameters:
      `value` - The Value to be converted
      `pattern` - The conversion pattern
    Returns:
      the converted value
    See Also:
      - `LocaleConvertUtilsBean.convert(Object, String)`

  - ### convert

    public static Object convert(String value, Class<?> clazz)

    Converts the specified value to an object of the specified class (if possible). Otherwise, return a String representation of the value.

    For more details see `LocaleConvertUtilsBean`

    Parameters:
      `value` - The String scalar value to be converted
      `clazz` - The Data type to which this value should be converted.
    Returns:
      the converted value
    See Also:
      - `LocaleConvertUtilsBean.convert(String, Class)`

  - ### convert

    public static Object convert(String value, Class<?> clazz, Locale locale, String pattern)

    Converts the specified value to an object of the specified class (if possible) using the conversion pattern. Otherwise, return a String representation of the value.

    For more details see `LocaleConvertUtilsBean`

    Parameters:
      `value` - The String scalar value to be converted
      `clazz` - The Data type to which this value should be converted.
      `locale` - The locale
      `pattern` - The conversion pattern
    Returns:
      the converted value
    See Also:
      - `LocaleConvertUtilsBean.convert(String, Class, Locale, String)`

  - ### convert

    public static Object convert(String value, Class<?> clazz, String pattern)

    Converts the specified value to an object of the specified class (if possible) using the conversion pattern. Otherwise, return a String representation of the value.

    For more details see `LocaleConvertUtilsBean`

    Parameters:
      `value` - The String scalar value to be converted
      `clazz` - The Data type to which this value should be converted.
      `pattern` - The conversion pattern
    Returns:
      the converted value
    See Also:
      - `LocaleConvertUtilsBean.convert(String, Class, String)`

  - ### convert

    public static Object convert(String[] values, Class<?> clazz)

    Convert an array of specified values to an array of objects of the specified class (if possible).

    For more details see `LocaleConvertUtilsBean`

    Parameters:
      `values` - Value to be converted (may be null)
      `clazz` - Java array or element class to be converted to
    Returns:
      the converted value
    See Also:
      - `LocaleConvertUtilsBean.convert(String[], Class)`

  - ### convert

    public static Object convert(String[] values, Class<?> clazz, Locale locale, String pattern)

    Convert an array of specified values to an array of objects of the specified class (if possible) using the conversion pattern.

    For more details see `LocaleConvertUtilsBean`

    Parameters:
      `values` - Value to be converted (may be null)
      `clazz` - Java array or element class to be converted to
      `locale` - The locale
      `pattern` - The conversion pattern
    Returns:
      the converted value
    See Also:
      - `LocaleConvertUtilsBean.convert(String[], Class, Locale, String)`

  - ### convert

    public static Object convert(String[] values, Class<?> clazz, String pattern)

    Convert an array of specified values to an array of objects of the specified class (if possible) using the conversion pattern.

    For more details see `LocaleConvertUtilsBean`

    Parameters:
      `values` - Value to be converted (may be null)
      `clazz` - Java array or element class to be converted to
      `pattern` - The conversion pattern
    Returns:
      the converted value
    See Also:
      - `LocaleConvertUtilsBean.convert(String[], Class, String)`

  - ### deregister

    public static void deregister()

    Remove any registered `LocaleConverter`.

    For more details see `LocaleConvertUtilsBean`

    See Also:
      - `LocaleConvertUtilsBean.deregister()`

  - ### deregister

    public static void deregister(Class<?> clazz, Locale locale)

    Remove any registered `LocaleConverter` for the specified locale and Class.

    For more details see `LocaleConvertUtilsBean`

    Parameters:
      `clazz` - Class for which to remove a registered Converter
      `locale` - The locale
    See Also:
      - `LocaleConvertUtilsBean.deregister(Class, Locale)`

  - ### deregister

    public static void deregister(Locale locale)

    Remove any registered `LocaleConverter` for the specified locale.

    For more details see `LocaleConvertUtilsBean`

    Parameters:
      `locale` - The locale
    See Also:
      - `LocaleConvertUtilsBean.deregister(Locale)`

  - ### getApplyLocalized

    public static boolean getApplyLocalized()

    Gets applyLocalized.

    For more details see `LocaleConvertUtilsBean`

    Returns:
      `true` if pattern is localized, otherwise `false`
    See Also:
      - `LocaleConvertUtilsBean.getApplyLocalized()`

  - ### getDefaultLocale

    public static Locale getDefaultLocale()

    Gets the `Locale` which will be used when no `Locale` is passed to a method.

    For more details see `LocaleConvertUtilsBean`

    Returns:
      the default locale
    See Also:
      - `LocaleConvertUtilsBean.getDefaultLocale()`

  - ### lookup

    public static <T> LocaleConverter<T> lookup(Class<T> clazz, Locale locale)

    Look up and return any registered `LocaleConverter` for the specified destination class and locale; if there is no registered Converter, return `null`.

    For more details see `LocaleConvertUtilsBean`

    Type Parameters:
      `T` - The converter type.
    Parameters:
      `clazz` - Class for which to return a registered Converter
      `locale` - The Locale
    Returns:
      The registered locale Converter, if any
    See Also:
      - `LocaleConvertUtilsBean.lookup(Class, Locale)`

  - ### register

    public static <T> void register(LocaleConverter<T> converter, Class<T> clazz, Locale locale)

    Register a custom `LocaleConverter` for the specified destination `Class`, replacing any previously registered converter.

    For more details see `LocaleConvertUtilsBean`

    Type Parameters:
      `T` - The converter type.
    Parameters:
      `converter` - The LocaleConverter to be registered
      `clazz` - The Destination class for conversions performed by this Converter
      `locale` - The locale
    See Also:
      - `LocaleConvertUtilsBean.register(LocaleConverter, Class, Locale)`

  - ### setApplyLocalized

    public static void setApplyLocalized(boolean newApplyLocalized)

    Sets applyLocalized.

    For more details see `LocaleConvertUtilsBean`

    Parameters:
      `newApplyLocalized` - `true` if pattern is localized, otherwise `false`
    See Also:
      - `LocaleConvertUtilsBean.setApplyLocalized(boolean)`

  - ### setDefaultLocale

    public static void setDefaultLocale(Locale locale)

    Sets the `Locale` which will be used when no `Locale` is passed to a method.

    For more details see `LocaleConvertUtilsBean`

    Parameters:
      `locale` - the default locale
    See Also:
      - `LocaleConvertUtilsBean.setDefaultLocale(Locale)`