jQuery in Action, 3rd edition
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

Number format

Dmitry Shekhter

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.
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
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)


So much trouble in the world -- Bob Marley
subject: Number format
It's not a secret anymore!