-1

我需要将票价金额传递给支付网关。它在英语语言环境中运行良好。当我将语言更改为缅甸语时,它会像这样000000၁၀၀၀၀၀改变,所以我的金额无效。即使我将货币设置为 Locale.English。但没有用。

更感谢你的回答!!!

 try {
            NumberFormat nf = NumberFormat.getInstance(Locale.ENGLISH);
            return nf.parse(s).doubleValue();
        } catch (java.text.ParseException e) {
            e.printStackTrace();
            return 0.0;
        }
4

1 回答 1

0

你可以这样做,

//calling of method
String your_amount= setCurrencyFormat(your_string);



private String setCurrencyFormat(String amt) {


        if (amt.equals("null") || amt.equals("")) {
            amt = "0";
        }

        double amount = Double.parseDouble(amt);


        //here i have done it for Indian currency i.e "in" you can opt for other countries currency

        Format formatter = NumberFormat.getCurrencyInstance(new Locale("en", "in"));
        return formatter.format(amount);


    }

注意:我以字符串格式获取我的金额,如果它是整数格式,您可以将您的 amt 转换为字符串

于 2018-04-27T09:03:37.070 回答