Parse the hour with Time#strptime
hour = 4
Time.strptime("#{hour}", "%H")
=> 2015-11-02 04:00:00 +0000
And then parse with Time#strftime
if you’re interested in the formatting.
Time.strptime("#{hour}", "%H").strftime("%H:%M")
=> "04:00"
solved How to parse time given an hours [closed]