@Test void formatNumberTest() { assertEquals("0", Converter.formatNumber(0, 5)); assertEquals("-5", Converter.formatNumber(-5, 5)); assertEquals("9", Converter.formatNumber(9, 9)); assertEquals("00", Converter.formatNumber(0, 10)); assertEquals("09", Converter.formatNumber(9, 10)); assertEquals("42", Converter.formatNumber(42, 99)); assertEquals("000", Converter.formatNumber(0, 100)); assertEquals("009", Converter.formatNumber(9, 100)); assertEquals("042", Converter.formatNumber(42, 100)); assertEquals("0042", Converter.formatNumber(42, 1000)); assertEquals("1000", Converter.formatNumber(1000, 1000)); assertEquals("0000", Converter.formatNumber(0, 1000)); }
public static String formatNumber(int number, int maxValue) { int numberOfDigits; if (maxValue < 10) numberOfDigits = 1; else if (maxValue < 100) numberOfDigits = 2; else if (maxValue < 1000) numberOfDigits = 3; else if (maxValue < 10000) numberOfDigits = 4; else numberOfDigits = 5; return StringUtils.leftPad(String.valueOf(number), numberOfDigits, '0'); }
Converter { public static String formatNumber(int number, int maxValue) { int numberOfDigits; if (maxValue < 10) numberOfDigits = 1; else if (maxValue < 100) numberOfDigits = 2; else if (maxValue < 1000) numberOfDigits = 3; else if (maxValue < 10000) numberOfDigits = 4; else numberOfDigits = 5; return StringUtils.leftPad(String.valueOf(number), numberOfDigits, '0'); } }
Converter { public static String formatNumber(int number, int maxValue) { int numberOfDigits; if (maxValue < 10) numberOfDigits = 1; else if (maxValue < 100) numberOfDigits = 2; else if (maxValue < 1000) numberOfDigits = 3; else if (maxValue < 10000) numberOfDigits = 4; else numberOfDigits = 5; return StringUtils.leftPad(String.valueOf(number), numberOfDigits, '0'); }  }
Converter { public static String formatNumber(int number, int maxValue) { int numberOfDigits; if (maxValue < 10) numberOfDigits = 1; else if (maxValue < 100) numberOfDigits = 2; else if (maxValue < 1000) numberOfDigits = 3; else if (maxValue < 10000) numberOfDigits = 4; else numberOfDigits = 5; return StringUtils.leftPad(String.valueOf(number), numberOfDigits, '0'); }  static Double createDouble(Object val); static Double createDouble(String val); static String formatNumber(int number, int maxValue); }
Converter { public static String formatNumber(int number, int maxValue) { int numberOfDigits; if (maxValue < 10) numberOfDigits = 1; else if (maxValue < 100) numberOfDigits = 2; else if (maxValue < 1000) numberOfDigits = 3; else if (maxValue < 10000) numberOfDigits = 4; else numberOfDigits = 5; return StringUtils.leftPad(String.valueOf(number), numberOfDigits, '0'); }  static Double createDouble(Object val); static Double createDouble(String val); static String formatNumber(int number, int maxValue);  }