mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 22:34:27 +02:00
8300818: Reduce complexity of padding with DateTimeFormatter
Reviewed-by: redestad, rriggs
This commit is contained in:
parent
ae5f678fba
commit
561ec9c5a0
2 changed files with 85 additions and 2 deletions
|
@ -2612,9 +2612,15 @@ public final class DateTimeFormatterBuilder {
|
|||
throw new DateTimeException(
|
||||
"Cannot print as output of " + len + " characters exceeds pad width of " + padWidth);
|
||||
}
|
||||
for (int i = 0; i < padWidth - len; i++) {
|
||||
buf.insert(preLen, padChar);
|
||||
var count = padWidth - len;
|
||||
if (count == 0) {
|
||||
return true;
|
||||
}
|
||||
if (count == 1) {
|
||||
buf.insert(preLen, padChar);
|
||||
return true;
|
||||
}
|
||||
buf.insert(preLen, String.valueOf(padChar).repeat(count));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue