Struts2 格式化數字

Struts2的支持本地化(localization)

下面是Java的Format

Output from  DecimalFormatDemo Program
valuepatternoutputExplanation
123456.789###,###.###123,456.789The pound sign (#) denotes a digit, the comma is a placeholder for the grouping separator, and the period is a placeholder for the decimal separator.
123456.789###.##123456.79The value has three digits to the right of the decimal point, but the pattern has only two. The format method handles this by rounding up.
123.78000000.000000123.780The pattern specifies leading and trailing zeros, because the 0 character is used instead of the pound sign (#).
12345.67$###,###.###$12,345.67The first character in the pattern is the dollar sign ($). Note that it immediately precedes the leftmost digit in the formatted output.
12345.67\u00A5###,###.###¥12,345.67The pattern specifies the currency sign for Japanese yen (¥) with the Unicode value 00A5.

SymbolDescription
0a digit
#a digit, zero shows as absent
.placeholder for decimal separator
,placeholder for grouping separator
Eseparates mantissa and exponent for exponential formats
;separates formats
-default negative prefix
%multiply by 100 and show as percentage
?multiply by 1000 and show as per mille
¤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
Xany other characters can be used in the prefix or suffix
'used to quote special characters in a prefix or suffix

下列代碼就是定義兩位數字(不足者補零)

#number
global.format.index={0,number,00}



最関鍵的一點! 該配置必須放在國際化文件中 我是放在 package.properties 中
經過測試  放在struts.properties中無效

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值