Substring method suppressing zeros

Folks,

Problem with substring...

I've a String d1 = '2005-03-01' and I need to extract 050301.

However when I use

String d2 = d1.substring(3,4) + d1.substring(6,7) + d1.substring(9,10) it gives me 531 and not 050301.

WHY?

How can I overcome this problem?

Thanks for your help in advance.

[339 byte] By [raj99a] at [2007-9-23]
# 1
Read the API for substring carefully. It should be...String d2 = d1.substring(2,4) + d1.substring(5,7) + d1.substring(8,10);
EllaOfTheCindersa at 2007-7-11 > top of java,Java Essentials,Java Programming...