I have this issue with new employee number format, when I search Active Directory for example with "07789", it returns me a result.But if I take the "0" off and search "7789" it will not find the record thinks 07789 and 7789 are different. But in the database the employee number field is an integer, so it always treats 07789 as 7789 and saves it in the database. Is there is any smarter way to handle this problem rather than changing the column data type and handle employee numbers as strings?
A:
Are the numbers always the same length? You could do something like this:
NumberFormat numberFormat = NumberFormat.getInstance();
numberFormat.setMinimumIntegerDigits(5);
numberFormat.setMaximumIntegerDigits(5);
numberFormat.setGroupingUsed(false);
String numberString = numberFormat.format((long) 7789);
System.out.println(numberString); //"07789"
dbyrne
2010-07-14 18:05:46
thanks dbyrne for the response. Well the numbers are not always the same length.
Padur
2010-07-19 20:55:10