Pad Number with Leading Zeros

1 Oct

Left pad a number with leading zeroes

Thanks to mauricekremer.dyndns.org for the concept and code. Below is my take on the function.

public static String PadZeros(Integer Num, Integer Len) {
  String s = String.valueOf(Num);
  while (s.length() < Len) s = '0' + s;
  return s;
}

2 Replies to “Pad Number with Leading Zeros

Comments are closed.