?

解决方案 »

  1.   


    DecimalFormat myFormatter = new DecimalFormat("###,###,###.##");
    String output = myFormatter.format(value);
    System.out.println(output); 
      

  2.   

    NumberFormat usf = NumberFormat.getCurrencyInstance(Locale.US);
    System.out.println(usf.format(999999999l));
    这样会带货币符号,怎么隐藏掉我还没有摸索出来,楼主努力了。
      

  3.   

    long num = 999999999L;// 1.通过 String.format 方法转换
    String str = String.format("%,d", num);
    System.out.println(str);

    // 2.通过格式化输出转换
    System.out.printf("%,d%n", num);以上两种方法都需 JDK 1.5 以上的版本。
      

  4.   

    要带改成其他货币符号的话,改里面的“$”就可以了。String str = String.format("$%,.2f", num + 0.0);
    System.out.println(str);
      

  5.   

    public String getCurrency (String aCurrency)
    {   if (aCurrency == null || aCurrency.length() == 0)
            return "";
        try
            {
            double dCurr= Double.parseDouble(aCurrency);
            dCurr /= 100;
            java.text.DecimalFormat dFmt= new java.text.DecimalFormat("#,##0.00");
            return dFmt.format(dCurr);
        }
        catch (Exception ex)
            {
            return aCurrency;
        }
    }自己写个bean放到top.jsp里
    以后每个jsp页面include这个top.jsp
    调用这个方法就可以
    just try