Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7014173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:29:12+00:00 2026-05-27T22:29:12+00:00

I have an EditText which should work as follows (Android 2.3.3): The user enters

  • 0

I have an EditText which should work as follows (Android 2.3.3):

The user enters for instance 10,40 (which is 10 Euro and 40 Cents in EU currency) – I want to then take that String input and convert it to a BigDecimal (or Number etc…) for instance, for further internal computation.

The same should work if the user enters 10.40 (which – in the case of US Dollar would amount to 10 Dollars and 40 Cents), then take that String input and convert it to a BigDecimal (or Number etc…) for instance.

I tried the following (based on Michael Petrotta’s answer here), which fails with “ParseException: Unparsable Number 10,40):

    // German input
    NumberFormat formatter = NumberFormat.getCurrencyInstance(Locale.GERMANY);
    // User input
    String value = "10,40";
    Number valueParsed = formatter.parse(value);

I also tried “10,40 €” to no avail. So either I am misunderstanding the purpose of NumberFormat.parse or I’m on a wrong track all together…? I really want to avoid using Regular Expressions to replace the comma in “10,40” for the version should work internationally and I’d like some clean, Locale-based approach.

EDIT

I found this question which addresses the same issue – the correct answer uses the same approach that I do, so I tried again (using France as a Locale this time) but it fails nonetheless, which seems quite odd… The comment under the referenced question suggested using replaceAll(“,”, “.”) which seems a bad idea to me, as some currencies use the comma as a divider for thousands, such as the US Dollar if I am not mistaken. I could however check the locale but that all seams shady 🙁 and potentially erroneous …

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T22:29:13+00:00Added an answer on May 27, 2026 at 10:29 pm

    It seems that you don’t really need currency format. Use NumberFormat.getNumberInstance() instead:

    String value = "10,40";
    double d = (Double)NumberFormat.getNumberInstance().parse(value);
    BigDecimal price = new BigDecimal(d);
    

    This will throw NumberFormatException though in case the user will enter the value in format inappropriate for his locale (e.g. “10,40” for US), but should work in regular case.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a EditText in android in which i want the user to enter
I have a edittext which the user enters some text into Once they press
I have an activity that has an EditText. After a user enters their text,
I have the following code which I think should work to force the keyboard
I am writing a simple android app which have a edittext and a button.
hi i want to create a a layout which must have an EditText and
I have an EditText that shows time. After user clicks the EditText I want
I have an EditText view which will allow the user to edit an address
I have an EditText. I want that after typing some text, when user presses
I have a text field in SQLite database, which I want the user to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.