• Post Reply Bookmark Topic Watch Topic
  • New Topic

convert String Value to Hexa Value ?  RSS feed

 
sachin kataria
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i want to convert String value to Hexa Value.
so, how i can do that ??
my String value len is 20.
i.e.
String str = "31080601090620003453";

so, how i convert this value to hexa value..

pls, help me....
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can't tell precisely what you're after, but I suspect that the parseInt() and toHexString() methods in the java.lang.Integer class will do exactly what you need.
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
20 places will exceed Long.MAX_VALUE of 9223372036854775807 19 places so, Use BigInteger

The second toString takes the radix of the number base. For hex it's 16.
[ August 31, 2006: Message edited by: Carl Trusiak ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!