How put zero prefix for Long value < 10 e.g for DB Id's?

trieriary

New Member
can somebody give litle advice about how give a zero prefix for output of Id's less than 10.For example i want show in output label a single id value which is type of Long in DB is this value \[code\]4\[/code\] but in output on some label i want show in form with leading zero so \[code\]04\[/code\] i found some case but its about \[code\]int primitive type\[/code\] so its there some casting what i cant solve, so far i have this code:\[code\]public String getCode() { PackageVersion packVer = BeanFactory.getHotelDAOService(PackageVersion.class).findOne(selectedDealerCodeId); if(packVer.getId() < 10){ String id = String.format("%0d", packVer.getId()); } return id;}\[/code\]above this method dont work, If somebody knows better and suitable solution about this please let me here post, Thanks
 
Back
Top