Duplicate of this one.
What would you use to pad zeroes to the left of a number in Flex/AS3?
Is there an equivalent to printf
or NumberFormat
that does this?
I'm looking for the nicest implementation of this or something similar:
public function zeroPad(number:int, width:int):String {
// number = 46, width = 4 would return "0046"
}
public function zeroPad(number:int, width:int):String {
var ret:String = ""+number;
while( ret.length < width )
ret="0" + ret;
return ret;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With