java将金额转化为千分位

15412年前 (2015-01-26)java技术5898

 

 String str = DecimalFormat.getNumberInstance().format(1245600000);

        String currecy = NumberFormat.getCurrencyInstance().format(1245600000);

        System.out.println("转换成Currency格式:"+currecy);

        System.out.println("转换成带千分位的格式:"+str); 
         输出结果:    
          转换成Currency格式:¥1,245,600,000.00
          转换成带千分位的格式:1,245,600,000
       也可以用js实现类似的功能:
      function convert(num)   
     {               var str = num+"";            
        var reg = /(-?/d+)(/d{3})/;    
        while(reg.test(str))       {
        str = str.replace(reg,"$1,$2");     
       }   
       return str;  

本文原创,转载必追究版权。

分享给朋友:

相关文章

使用Myeclipse 8.5开发基于JAX-WS的Web service实例

 本文为Web service 开发入门篇,主要介绍在Myeclipse 8.5环境下开发Web service的服务程序和客户端程序的基本流程。 在Weblogic 11g...

get/post方式调用http接口

get/post方式调用http接口

 1. 项目环境如下:myeclipse8.5 、tomcat5.0/weblogic、xp、JDK:开发1.5,编译1.4为了方便,在原来的web项目UpDown中新建了一个httpcal...

java.lang.NoClassDefFoundError: org/apache/juli/logging/LogFactory

将项目部署好后,启动tomcat后报错,java.lang.NoClassDefFoundError: org/apache/juli/logging/LogFactory报这个错说明你用的是tomc...

com.sun.xml.ws.transport.http.servlet.WSServletContextListener

ProblemDeploying a JAX-WS web service on Tomcat, hits following error message :java.lang.ClassNotFou...

UUID 生成方法

import java.util.UUID;/**     * UUID 生成方法     * @return uuid &nbs...

java实现日期加1

直接附代码:      public static final Date getNextDay(){...

评论列表

上海app开发
上海app开发
12年前 (2015-03-08)

好久没来 帮着顶顶

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。