2

I want to generate a sequence number starting from 00000001,00000002....(i need all these zero as well)Please help me..Thanks in advance..

1
  • None of the answer are from XSLT, and you've accepted one. Retagging Commented Mar 22, 2011 at 23:18

3 Answers 3

7

You can just generate the sequence numbers as integers and then format them like this:

String.format("%08d", yournumber);

See this question: How can I pad an integers with zeros on the left?

Sign up to request clarification or add additional context in comments.

Comments

2

You just need to use string formatting to pad numbers with zeros:

for (int i = 1; i < 1000; i++) {
    String sequence = String.format("%08d", i);
}

Comments

2

You can just maintain that variable as an integer and use String.format to format it.

String s = String.format ("%08d", 42); // gives you "00000042"

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.