formatIntoBuffer method

String formatIntoBuffer(
  1. StringBuffer sb,
  2. EllaDateTime dateTime, [
  3. String? formatString
])

Implementation

String formatIntoBuffer(StringBuffer sb, EllaDateTime dateTime, [String? formatString])
{
  // Apply default format string if not set.
  formatString ??= getDefaultFormatString();

  this.dateTime = dateTime;

  this.sb = sb;

  // Parse format.
  String c;
  int count; // How many in field
  for (int i=0; i < formatString.length; i++)
  {
    c = formatString[i];
    count = 0;
    // Count field (how many chars match exactly)
    while ( i + count < formatString.length && formatString[i + count] == c )
    {
      count++;
    }

    formatField(c, count);

    i += count - 1;
  }

  return sb.toString();
}