@Target(value={METHOD,FIELD,PARAMETER}) @Retention(value=RUNTIME) public @interface NumberFormat
java.lang.Number
type.
For style-based formatting, set the style()
attribute to be the desired NumberFormat.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 with a style of NumberFormat.Style.NUMBER
.
NumberFormat
Modifier and Type | Optional Element and Description |
---|---|
String |
pattern
The custom pattern to use to format the field.
|
NumberFormat.Style |
style
The style pattern to use to format the field.
|
public abstract NumberFormat.Style style
NumberFormat.Style.NUMBER
for general-purpose number formatter.
Set this attribute when you wish to format your field in accordance with a common style other than the default style.public abstract String pattern