| Author |
Number Format Exception (double to Long)
|
Chris Cornelius
Ranch Hand
Joined: Aug 02, 2005
Posts: 48
|
|
I have an issue with trying convert a double to a Long value. I need to convert the double to Long so that it can be stored in a bean of type Long. Here is the code snippet: I am getting the following exception: java.lang.NumberFormatException: For input string: "1230.45" What am I missing? Thanks in advance. Chris
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14672
|
|
What am I missing?
Long does not include decimals. If that's what you want, you can cast a double to a long and chop off the decimal :
|
[My Blog]
All roads lead to JavaRanch
|
 |
Chris Cornelius
Ranch Hand
Joined: Aug 02, 2005
Posts: 48
|
|
Thanks Christope, So it looks like my options are to change the bean type to either a string or double to keep the decimal intact. Chris
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26218
|
|
|
Or a BigDecimal object.
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
 |
|
|
subject: Number Format Exception (double to Long)
|
|
|