File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Number format Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Number format" Watch "Number format" New topic
Author

Number format

Dmitry Shekhter
Greenhorn

Joined: Feb 21, 2001
Posts: 26
I'm implementing the Comparator interface to compare two numeric values against each other. The values come in as a string consisting of 13 characters (ex: 2000102400001). I need to convert this string into a numeric value for comparison. Problem is the numeric formats I've tried(integer, long) throw a compile error "out of range". Any clues?
Thanks in advance.
Dmitry
jason adam
Chicken Farmer ()
Ranch Hand

Joined: May 08, 2001
Posts: 1932
Check out the API for BigInteger, I'm sure you will find everything you need in there
Jason
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
Use parseLong. Remember to enclose it within try/catch and catch NumberFormatException
long yourNum = Long.parseLong(yourString)

Bosun


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Number format
 
Similar Threads
String array generation with distinct values
Numberformat exception
Regular expression for numeric copy
reading excel file using jdbc [help me]
How to get a String randomly?