开发者

Problem in converting Hexadecimal value to bigInteger

I have a string uniqueCode of length 16.

String uniqueCode = accountno + extracode;

accountno is of length 6 and extracode is populated in following way:

String extraCode = branch + loanCode + openingDateStr ;
BigInteger hexaCode = new BigInteger(extraCode);开发者_StackOverflow社区 
extraCode = hexaCode.toString(16); // hexa bit

Now i want to get back branch,loancode and openingdatestr from this uniquecode. how to do this?


To get back the original string from extraCode in hex:

BigInteger decCode = new BigInteger(extraCode, 16);
extraCode = decCode.toString(10);

Now you can extract the components from extraCode by their length. For instance, if branch has 6 digits and loanCode has 4 digits, you can do:

String branch = extraCode.substring(0, 6);
String loanCode = extraCode.substring(6, 10);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜