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

Introduce DecimalDigits.appendPair for efficient two-digit formatting and refactor DateTimeHelper

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • 26
    • None
    • core-libs
    • None

      This PR introduces a new efficient API for appending two-digit integers to StringBuilders and refactors DateTimeHelper to leverage this new functionality.

      Changes include:

      New appendPair method for efficient two-digit integer formatting (00-99):

      Added AbstractStringBuilder.appendPair(int i) with core implementation
      Added JavaLangAccess.appendPair(StringBuilder, int) for internal access
      Added System.JavaLangAccessImpl.appendPair(StringBuilder, int) bridge
      Added DecimalDigits.appendPair(StringBuilder, int) public static utility method
      Enhanced Javadoc documentation for all new methods
      Refactored DateTimeHelper to use the new DecimalDigits.appendPair:

      Updated DateTimeHelper.formatTo methods for LocalDate and LocalTime
      Replaced manual formatting logic with the new efficient two-digit appending
      Improved code clarity and consistency in date/time formatting
      These changes improve code clarity and performance when formatting two-digit numbers, particularly in date/time formatting scenarios.

            swen Shaojin Wen
            swen Shaojin Wen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: