# toString method

1. @override

String toString()
override

Returns a string representation of the time in `HH:mm:ss` or `HH:mm:ss.SSS` format.

### Example

    print(LocalTime(9, 5, 3));         // 09:05:03
    print(LocalTime(14, 8, 22, 70));   // 14:08:22.070

## Implementation

    @override
    String toString() {
      final h = hour.toString().padLeft(2, '0');
      final m = minute.toString().padLeft(2, '0');
      final s = second.toString().padLeft(2, '0');

      if (millisecond.isEqualTo(0)) {
        return '$h:$m:$s';
      } else {
        final ms = millisecond.toString().padLeft(3, '0');
        return '$h:$m:$s.$ms';
      }
    }