FormattedValueConverter (Grails 2.3.8)
Date: 2014-04-24

Overview | Package | Class | Deprecated | Index | Help
| Groovy Documentation
| FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | METHOD | DETAIL: FIELD | METHOD

## org.grails.databinding.converters
[Java] Interface FormattedValueConverter

    public interface FormattedValueConverter

Classes which implement this interface may participate in the data binding process as formatted value converters.

    import org.grails.databinding.converters.FormattedValueConverter

    class FormattedStringValueConverter implements FormattedValueConverter {
        def convert(value, String format) {
            if('UPPERCASE' == format) {
                value = value.toUpperCase()
            } else if('LOWERCASE' == format) {
                value = value.toLowerCase()
            }
            value
        }

        Class getTargetType() {
            // specifies the type to which this converter may be applied
            String
        }
    }

Authors:
  Jeff Brown

See Also:
  BindingFormat
  SimpleDataBinder
  SimpleDataBinder.registerFormattedValueConverter

Since:
  2.3

Method Summary
`java.lang.Object` | `convert(java.lang.Object value, java.lang.String format)` Return a formatted value
`java.lang.Class` | `getTargetType()` @return the output type of this converter

Method Detail

### convert

    public java.lang.Object convert(java.lang.Object value, java.lang.String format)

  Return a formatted value
  Parameters:
    `value` - The value to be formatted
    `format` - The format String
  Returns:
    the formatted value

### getTargetType

    public java.lang.Class getTargetType()

  Returns:
    the output type of this converter

Groovy Documentation