How to format a number 0..9 to display with 2 digits (it’s NOT a date) October 5, 2022 by Tarik You can use: String.format("%02d", myNumber) See also the javadocs