0

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); 
extraCode = hexaCode.toString(16); // hexa bit

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

1
  • 1
    Why does this need to be a BigInteger? You only normally convert to an integer if you want to perform some form of math operation on it. If it's simply an identifier you can leave it as a String. Commented Feb 11, 2011 at 7:59

1 Answer 1

1

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);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.