逗号分隔符在字符串变量中 [英] comma separator in a string variable

查看:103
本文介绍了逗号分隔符在字符串变量中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

如何格式化字符串数字以使其具有逗号和轮?

我有一个字符串变量(这是一个字符串格式的数字),现在我想使用逗号分隔每三个数字。我该怎么做?
我的技术是Struts2

I have a string variable (That is a number in string format) and now I want to use a comma for separation for every three digits. how can I do it? My technology is Struts2

推荐答案

例如:turn 100000 to 100,000

For Example:turn 100000 to 100,000

public class number
{
    public static void main(String args [])
    {
        double d = 123456.78;
        DecimalFormat df = new DecimalFormat("###,### ");
        System.out.
        println(df.format(d));
    }
}

这篇关于逗号分隔符在字符串变量中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆