Convert 1 to 01

前端 未结 11 1623
逝去的感伤
逝去的感伤 2021-02-07 04:09

I have an int between 1 - 99. How do I get it to always be a double digit, ie: 01, 04, 21?

11条回答
  •  天命终不由人
    2021-02-07 05:08

    You can't do it just using an int. You'll have to convert between Strings (for display) and back to ints (for calculations). You can use the Java Formatter to format your Strings based on the input.

提交回复
热议问题