To remove that character, we can use its Unicode representation and replace that:DecimalFormat df = new DecimalFormat("#,###.00");String str = df.format(new BigDecimal("1250"));System.out.println(str.replace(",", ".").replace("\u00A0", ""));对于更通用的解决方案,不依赖于当前的语言环境,我们可以检索分组分隔符并直接使用它:For a more general solution, not depending on the current locale, we could retrieve the grouping separator and use that directly:DecimalFormat df = new DecimalFormat("#,###.00");String groupingSeparator = String.valueOf(df.getDecimalFormatSymbols().getGroupingSeparator());String str = df.format(new BigDecimal("1250"));System.out.println(str.replace(",", ".").replace(groupingSeparator, "")); 这篇关于用格式值替换DecimalFormat的分组分隔符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-04 02:55