withLeadingZeros static method

String withLeadingZeros(
  1. int value,
  2. int width
)

Formats a number with leading zeros

Example:

NumberFormatters.withLeadingZeros(5, 3); // '005'

Implementation

static String withLeadingZeros(int value, int width) {
  return value.toString().padLeft(width, '0');
}