public final class NumberPattern extends Object
Symbol Location Localized? Meaning 0
Number Yes 每一个0表示一位阿拉伯数字,如果该位不存在,则显示0
如果对应位置上没有数字,则用零代替#
Number Yes 每一个#表示一位阿拉伯数字,如果该位不存在,则不显示
如果对应位置上没有数字,则保持原样(不用补);如果最前、后为0,则保持为空..
Number Yes 小数点分隔符或货币的小数分隔符 -
Number Yes Minus sign 代表负号 ,
Number Yes Grouping separator分组分隔符 E
Number Yes Separates mantissa and exponent in scientific notation. Need not be quoted in prefix or suffix. 分隔科学计数法中的尾数和指数 ;
Subpattern boundary Yes Separates positive and negative subpatterns %
Prefix or suffix Yes 数字乘以100并显示为百分数 \u2030
Prefix or suffix Yes 乘以1000并显示为千分数 ¤
(\u00A4
)Prefix or suffix No Currency sign, replaced by currency symbol. If doubled, replaced by international currency symbol. If present in a pattern, the monetary decimal separator is used instead of the decimal separator.
货币记号,由货币号替换.
如果两个同时出现,则用国际货币符号替换; 如果出现在某个模式中,则使用货币小数分隔符,而不使用小数分隔符'
Prefix or suffix No 用于在前缀或后缀中为特殊字符加引号, 例如 "'#'#" 将 123 格式化为 "#123".
要创建单引号本身,则连续使用两个单引号,例如"# o''clock"
DecimalFormat
Modifier and Type | Field and Description |
---|---|
static String |
NO_SCALE
整数,不含小数
"#" . |
static String |
PERCENT_WITH_1POINT
百分数的表达式(1位小数点)
"#0.0%" . |
static String |
PERCENT_WITH_2POINT
百分数的表达式(2位小数点)
"#0.00%" . |
static String |
PERCENT_WITH_NOPOINT
百分数的表达式(不带小数)
"##%" . |
static String |
TWO_DECIMAL_POINTS
(2位小数点)
"#0.00" . |
public static final String NO_SCALE
"#"
.
88.6 会被格式化成 89 -88.6 会被格式化成 -89
public static final String TWO_DECIMAL_POINTS
"#0.00"
.
88.6 会被格式化成 88.60 -88.067 会被格式化成 -88.07
public static final String PERCENT_WITH_NOPOINT
"##%"
.
0 会被格式化成 0% 1 会被格式化成 100% 100 会被格式化成 10000%
public static final String PERCENT_WITH_1POINT
"#0.0%"
.
0 会被格式化成 0.0% 1 会被格式化成 100.0% 100 会被格式化成 10000.0%
public static final String PERCENT_WITH_2POINT
"#0.00%"
.
0 会被格式化成 0.00% 1 会被格式化成 100.00% 100 会被格式化成 10000.00%
Copyright © 2008-2019 by feilong