June 21st, 2001, 06:24 AM
How to covert a 2 digit number to a 4 digit number?
Anyone know what to use to convert an 2 digit integer e.g. 93, to a 4-digit integer e.g. 0093?
June 21st, 2001, 09:10 AM
convert 93 to an Integer, then concatenate it with 00, then convert back to a string. note, you can't keep "0093" in an int or a float as it will truncate the extra zeroes.
int a = 93;
Integer b= new Integer(a);
StringBuffer c = new StringBuffer("00" + b.toString());
string d = c.toString();
this would be a wordy way of doing it, but it illustrates what needs to be done.