打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
JSTL fmt:formatNumber 数字、货币格式化 - run_fan - Ja...
Java代码
 
  1. <fmt:formatNumber value="12" type="currency" pattern="$.00"/> //-- $12.00    
  2.   
  3. <fmt:formatNumber value="12" type="currency" pattern="$.0#"/> //-- $12.0    
  4.   
  5. <fmt:formatNumber value="1234567890" type="currency"/> //-- $1,234,567,890.00(那个货币的符号和当前web服务器的 local 设定有关)    
  6.   
  7. <fmt:formatNumber value="123456.7891" pattern="#,#00.0#"/>// -- 123,456.79    
  8.   
  9. <fmt:formatNumber value="123456.7" pattern="#,#00.0#"/> //-- 123,456.7    
  10.   
  11. <fmt:formatNumber value="123456.7" pattern="#,#00.00#"/>// -- 123,456.70    
  12.   
  13. <fmt:formatNumber value="12" type="percent" /> //-- 1,200% (type 可以是currency、 number、 和percent)。   

 

 

java格式化输出:

Java代码
 
  1. DecimalFormat df = new DecimalFormat("格式");   
  2. String fmt =df.format(double);  

 

符号                  意义
0                     一个数位
#                     一个数位,前导零和追尾零不显示
.                      小数点分割位置
,                     组分隔符的位置
-                      负数前缀
%                    用100乘,并显示百分号
其他任何符号    在输出字符串中包括指定符号

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
JSTL fmt 的一些用法
<fmt:formatNumber> 标签 | w3cschool菜鸟教程
数据格式化
jstl 格式化时间,数字方法集合
如何把double类型四舍五入到小数后两位
EL表达式取整问题
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服