File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Number format

 
Dmitry Shekhter
Greenhorn
Posts: 26
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1932
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out the API for BigInteger, I'm sure you will find everything you need in there
Jason
 
Bosun Bello
Ranch Hand
Posts: 1510
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use parseLong. Remember to enclose it within try/catch and catch NumberFormatException
long yourNum = Long.parseLong(yourString)

Bosun
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic