Class NumberToStringConverter

Object
NumberToStringConverter

public class NumberToStringConverter extends Object
Converts a number to a strings of constant width by padding with leading zeros.
Author:
Owen Feehan
  • Constructor Details

    • NumberToStringConverter

      public NumberToStringConverter(int maxNumberToRepresent)
      Creates with a constant width just enough to be able to represent maxNumberToRepresent.
      Parameters:
      maxNumberToRepresent - the maximimal number that needs to be converted.
  • Method Details

    • convert

      public String convert(int number)
      Converts number to a string, padding with leading zeros if necessary to ensure the desired width.
      Parameters:
      number - the number to convert to a string
      Returns:
      the string representation of number, maybe padded with leading zeros