JSTL fmt:formatNumber 数字、货币格式化
2010-01-25 19:16
405 查看
JSTL fmt:formatNumber 数字、货币格式化
关键字: fmt:formatnumberJava代码
<fmt:formatNumber value=
"12"
type=
"currency"
pattern=
"$.00"
/>
//-- $12.00
<fmt:formatNumber value="12"
type=
"currency"
pattern=
"$.0#"
/>
//-- $12.0
<fmt:formatNumber value="1234567890"
type=
"currency"
/>
//-- $1,234,567,890.00(那个货币的符号和当前web服务器的 local 设定有关)
<fmt:formatNumber value="123456.7891"
pattern=
"#,#00.0#"
/>
// -- 123,456.79
<fmt:formatNumber value="123456.7"
pattern=
"#,#00.0#"
/>
//-- 123,456.7
<fmt:formatNumber value="123456.7"
pattern=
"#,#00.00#"
/>
// -- 123,456.70
<fmt:formatNumber value="12"
type=
"percent"
/>
//-- 1,200% (type 可以是currency、 number、 和percent)。
<fmt:formatNumber value="12" type="currency" pattern="$.00"/> //-- $12.00 <fmt:formatNumber value="12" type="currency" pattern="$.0#"/> //-- $12.0 <fmt:formatNumber value="1234567890" type="currency"/> //-- $1,234,567,890.00(那个货币的符号和当前web服务器的 local 设定有关) <fmt:formatNumber value="123456.7891" pattern="#,#00.0#"/>// -- 123,456.79 <fmt:formatNumber value="123456.7" pattern="#,#00.0#"/> //-- 123,456.7 <fmt:formatNumber value="123456.7" pattern="#,#00.00#"/>// -- 123,456.70 <fmt:formatNumber value="12" type="percent" /> //-- 1,200% (type 可以是currency、 number、 和percent)。
java格式化输出:
Java代码
DecimalFormat df =
new
DecimalFormat(
"格式"
);
String fmt =df.format(double
);
DecimalFormat df = new DecimalFormat("格式"); String fmt =df.format(double);
符号 意义
0 一个数位
# 一个数位,前导零和追尾零不显示
. 小数点分割位置
, 组分隔符的位置
- 负数前缀
% 用100乘,并显示百分号
其他任何符号 在输出字符串中包括指定符号
相关文章推荐
- JSTL fmt:formatNumber 数字、货币格式化
- JSTL fmt:formatNumber 数字、货币格式化
- JSTL fmt:formatNumber日期、 数字、货币格式化
- JSTL fmt:formatNumber 数字、货币格式化
- JSTL fmt:formatNumber日期、 数字、货币格式化
- JSTL fmt:formatNumber 数字、货币格式化
- JSTL fmt:formatNumber日期、 数字、货币格式化
- JSTL fmt:formatNumber 数字、货币格式化
- JSTL fmt:formatNumber日期、 数字、货币格式化
- JSTL fmt:formatNumber 对数据的日期、 数字、货币格式化
- JSTL fmt:formatNumber日期、 数字、货币格式化
- JSTL fmt:formatNumber 数字、货币格式化
- JSTL fmt:formatNumber日期、 数字、货币格式化
- JSTL fmtformatNumber日期、 数字、货币格式化
- JSTL fmt:formatNumber日期、 数字、货币格式化
- JSTL fmt:formatNumber 数字、货币格式化
- JSTL fmt:formatNumber日期、 数字、货币格式化
- JSTL fmt:formatNumber日期、 数字、货币格式化
- JSTL fmt:formatNumber 数字、货币格式化
- JSTL fmt:formatNumber日期、 数字、货币格式化