0
NumberFormat.getNumberInstance().format(new Integer(1000)) // 1,000 in US locale, 1 000 in France

"1,000" -> 1000 "1 000" -> 1000

Are there any methods or ways to convert number-formatted number to integer in any locales?

Pytan
  • 1,138
  • 11
  • 28
  • Although ... you don't know the locale, right? But if you don't know the locale, then what is the number `1.000` for you? "1" with US local or 1000 with some european locales? – Tom Dec 23 '20 at 14:59
  • @Tom > Does this answer your question? How do I convert a String to Double in Java using a specific locale? kind of... but we don't know which locale is used. Yeah that's the point I'm stuck with – Pytan Dec 23 '20 at 15:01

1 Answers1

0

You might be interested in the NumberFormat class, it allows you to format based on locale, which you just need to find out to access the right one:

NumberFormat nf = NumberFormat.getInstance(Locale.FRENCH);

myNumber = nf.parse(<String or Number here>);

To get the locale, you need, read here

hwgn
  • 130
  • 2
  • 6