NumberFormatException when parsing Hindi numbers

后端 未结 5 1861
走了就别回头了
走了就别回头了 2021-01-25 05:33

I have an android application and today I have got a crash report which contains this: \"NumberFormatException\"

Th

5条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-25 06:03

    You can use Character.getNumericValue(char).

    The good thing about this method is that it can do what you need.

    But to work in valid you should implement in your application support for local.

    NumberFormat format = NumberFormat.getInstance(new Locale("hin","IND"));
    
    Number parse = format.parse("१");
    
    System.out.println(parse);
    

    Prints 1.

提交回复
热议问题