Android examples for java.lang:Integer
add Zero for single digit number
public class Main { public static String addZerodata(int m) { if (m < 10) { return "0" + (String.valueOf(m)); } else {//from w w w. ja va 2s . com return String.valueOf(m); } } public static String addZerodata(String str) { int m = Integer.parseInt(str); if (m < 10) { return "0" + (String.valueOf(m)); } else { return str; } } }