Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8300818

Reduce complexity of padding with DateTimeFormatter

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 21
    • None
    • core-libs
    • None
    • b21

      Currently it's O(n) - we do `n` shifts of bytes within `StringBuilder`. This can be reduced to O(1) improving the code like:

      DateTimeFormatter dtf = new DateTimeFormatterBuilder()
        .appendLiteral("Date:")
        .padNext(50, '\t')
        .append(DateTimeFormatter.ISO_DATE)
        .toFormatter();
      String text = dtf.format(LocalDateTime.now());

            stsypanov Sergey Tsypanov
            stsypanov Sergey Tsypanov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: