Formatting integer (2 printed as 02)

I want to format an integer as hours and minutes.

Of course it's easy to write this myself, but let's respect DRY!

Is there a method I can use so that integers are converted to strings of
2 digits?

So:
2 --> 02
11 --> 11
4 --> 04

sprintf("%02d", 4) => 04

-philip