Ruby on Rails Discussions
Formatting integer (2 printed as 02)
rubyonrails-talk
Thiago_Jackiw
(Thiago Jackiw)
March 28, 2007, 11:08pm
1
Yep, you can use sprintf:
sprintf("%0.2d", 4)
=> "04"
Related topics
Topic
Replies
Views
Activity
Formatting integer (2 printed as 02)
rubyonrails-talk
0
127
March 29, 2007
Formatting integer (2 printed as 02)
rubyonrails-talk
0
130
March 28, 2007
how to format floating point number
rubyonrails-talk
0
133
September 11, 2006
how to trim the 0
rubyonrails-talk
0
102
October 11, 2007
preceding zero
rubyonrails-talk
8
211
September 28, 2009