other register

Monday, April 19, 2010

Number format

When comes to custom number formatting, you might have a user case like room number 001, 075. How to format this:

NumberFormat formatter = new DecimalFormat("000")
def s
s = formatter.format(1) // the result will be 001
s = formatter.format(75) // the result will be 075

No comments: