• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Number Conversion Problem

 
Ranch Hand
Posts: 158
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear All.

I am using JTable having values in column 3.
I am getting values from it using jTable.getValueAt(1,1).toString;
Then i use Double/Float/Integer/Long etc to convert data.
My data having values 999,999,999,999.99
Problem is that thru any of above option i get 9.9999999999999
in sum of different values. My jTable contents number of values positive and negative.

Can anyone help me where i m wrong or is there any other way to solve my this problem.

I am using the same below method except Double.parseDouble(), Integer.parseInt() etc etc

 
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem is that the parse methods of Double, etc. all assume the String has no formatting elements excpet . Since yours does, you should use DecimalFormat to parse String values with , seperators.
http://java.sun.com/j2se/1.5.0/docs/api/java/text/DecimalFormat.html
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic