need space between currency symbol and amount

前端 未结 5 870
余生分开走
余生分开走 2021-02-13 13:09

I\'m trying to print INR format currency like this:

NumberFormat fmt = NumberFormat.getCurrencyInstance();
fmt.setCurrency(Currency.getInstance(\"INR\"));
fmt.fo         


        
5条回答
  •  耶瑟儿~
    2021-02-13 13:30

    See if this works:

    DecimalFormat fmt = (DecimalFormat) NumberFormat.getInstance();
    fmt.setGroupingUsed(true);
    fmt.setPositivePrefix("Rs. ");
    fmt.setNegativePrefix("Rs. -");
    fmt.setMinimumFractionDigits(2);
    fmt.setMaximumFractionDigits(2);
    fmt.format(30382.50);
    

    Edit: Fixed the first line.

提交回复
热议问题