Top Description Inners Methods
org.springframework.format.annotation

public @Interface NumberFormat

extends Annotation
Annotations
@Documented
@Retention:RUNTIME
@Target:METHOD, FIELD, PARAMETER, ANNOTATION_TYPE
Imports
java.lang.annotation.Documented, .ElementType, .Retention, .RetentionPolicy, .Target

Declares that a field or method parameter should be formatted as a number.

Supports formatting by style or custom pattern string. Can be applied to any JDK Number type such as Double and Long.

For style-based formatting, set the style attribute to be the desired Style. For custom formatting, set the pattern attribute to be the number pattern, such as #, ###.##.

Each attribute is mutually exclusive, so only set one attribute per annotation instance (the one most convenient one for your formatting needs). When the pattern attribute is specified, it takes precedence over the style attribute. When no annotation attributes are specified, the default format applied is style-based for either number of currency, depending on the annotated field or method parameter type.

Authors
Keith Donald, Juergen Hoeller
Since
3.0
See Also
java.text.NumberFormat

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
NumberFormat.Style

Common number format styles.

Method Summary

Modifier and TypeMethod and Description
public String
pattern()

The custom pattern to use to format the field.

public NumberFormat.Style
style()

The style pattern to use to format the field.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

patternback to summary
public String pattern()

The custom pattern to use to format the field.

Defaults to empty String, indicating no custom pattern String has been specified. Set this attribute when you wish to format your field in accordance with a custom number pattern not represented by a style.

styleback to summary
public NumberFormat.Style style()

The style pattern to use to format the field.

Defaults to Style#DEFAULT for general-purpose number formatting for most annotated types, except for money types which default to currency formatting. Set this attribute when you wish to format your field in accordance with a common style other than the default style.

org.springframework.format.annotation back to summary

public final Enum NumberFormat.Style

extends Enum<NumberFormat.Style>
Class Inheritance

Common number format styles.

Field Summary

Modifier and TypeField and Description
public static final NumberFormat.Style
CURRENCY

The currency format for the current locale.

public static final NumberFormat.Style
DEFAULT

The default format for the annotated type: typically 'number' but possibly 'currency' for a money type (e.g. javax.money.MonetaryAmount).

public static final NumberFormat.Style
NUMBER

The general-purpose number format for the current locale.

public static final NumberFormat.Style
PERCENT

The percent format for the current locale.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static NumberFormat.Style
public static NumberFormat.Style[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

CURRENCYback to summary
public static final NumberFormat.Style CURRENCY

The currency format for the current locale.

DEFAULTback to summary
public static final NumberFormat.Style DEFAULT

The default format for the annotated type: typically 'number' but possibly 'currency' for a money type (e.g. javax.money.MonetaryAmount).

Since
4.2
NUMBERback to summary
public static final NumberFormat.Style NUMBER

The general-purpose number format for the current locale.

PERCENTback to summary
public static final NumberFormat.Style PERCENT

The percent format for the current locale.

Constructor Detail

Styleback to summary
private Style()

Method Detail

valueOfback to summary
public static NumberFormat.Style valueOf(String name)
valuesback to summary
public static NumberFormat.Style[] values()