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 8285101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:22:05+00:00 2026-06-08T11:22:05+00:00

I am trying to parse a double from an edittext but i keep getting

  • 0

I am trying to parse a double from an edittext but i keep getting a number format exception error.

i initially tried this…

premiumvalue = Double.parseDouble(premium.getText().toString());         
amountweightvalue = Double.parseDouble(amountweight.getText().toString());

Then attempted this…to no avail.

try{
    premiumvalue = Double.parseDouble(premium.getText().toString());
} catch (final NumberFormatException e) {
    premiumvalue = 0;
}
try{
    amountweightvalue = Double.parseDouble(amountweight.getText().toString());
} catch (final NumberFormatException e) {
    premiumvalue = 0;
}

I’m a noob and any help fixing this would be greatly appreciated.

  • 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-06-08T11:22:07+00:00Added an answer on June 8, 2026 at 11:22 am

    I have test your code test your code myself and find the following possibility to find NumberFormatException:

    1. if EditText value is blank, So apply condition for EditText blank value.
    2. if EditText value is only dot(.), So apply condition for EditText dot value.

    in your comment you are saying that you are using this

    String text = premium.getText().toString();
    
    if(text.equals(".")||text.equals("-.")||text.equals(""))
     { 
        premium.setText("0");
     }
    

    so my point is that

    1. are you using same thing for both premium and amountweight EditText and then parse string to double??
    2. and why you need to check condition for ‘_’ because if you set android:inputType="numberDecimal" attribute for EditText then EditText only accept 0-9 and . value.
    3. you don’t need to trim EditText value bacuse Edittext do not accept blank space if you are using android:inputType="numberDecimal" attribute.
    4. don’t need to check null condition because EditText never return null value.

    I have test your code lot of way and do not find NumberFormatException if i follow above points.

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

Sidebar

Related Questions

Trying to parse some XML but apparently this is too much for a lazy
I am trying to parse string 0.0000 with double.TryParse() but I have no idea
I am trying to parse data I am getting from an arduino robot I
I am trying to use strptime() to parse dates from a factor variable--but there
Trying to parse Maplines for an airport. Each airport can have X number of
I am trying to convert the user's input from the EditText into a Big
I'm trying to write a small baseball statistics program using data from retrosheet.org, but
i am trying to parse this xml file into an object to use the
I'm trying to parse a binary file format in Haskell (Apple's binary property list
I am trying to get cells from excel into csharp but not sure what's

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.