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);
精彩评论