Java examples for java.util:Date Format
Returns a string representation of number with at least 2 digits
//package com.java2s; public class Main { public static void main(String[] argv) throws Exception { int number = 2; System.out.println(printTwoDigits(number)); }//from www .j a va2s. c o m /** * Returns a string representation of number with at least 2 digits */ private static String printTwoDigits(int number) { if (number > 9) { return String.valueOf(number); } else { return "0" + number; } } }