mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 22:34:27 +02:00
8336792: DateTimeFormatterBuilder append zeros based on StringBuilder.repeat
Reviewed-by: liach, rriggs, naoto
This commit is contained in:
parent
e7e48a780a
commit
e3acf4c627
1 changed files with 8 additions and 10 deletions
|
@ -2965,8 +2965,9 @@ public final class DateTimeFormatterBuilder {
|
|||
}
|
||||
}
|
||||
char zeroDigit = decimalStyle.getZeroDigit();
|
||||
for (int i = 0; i < minWidth - size; i++) {
|
||||
buf.append(zeroDigit);
|
||||
int zeros = minWidth - size;
|
||||
if (zeros > 0) {
|
||||
buf.repeat(zeroDigit, zeros);
|
||||
}
|
||||
if (zeroDigit == '0' && value != Long.MIN_VALUE) {
|
||||
buf.append(Math.abs(value));
|
||||
|
@ -3410,17 +3411,16 @@ public final class DateTimeFormatterBuilder {
|
|||
if (decimalPoint) {
|
||||
buf.append(decimalStyle.getDecimalSeparator());
|
||||
}
|
||||
for (int i = 0; i < width; i++) {
|
||||
buf.append(zero);
|
||||
}
|
||||
buf.repeat(zero, width);
|
||||
}
|
||||
} else {
|
||||
if (decimalPoint) {
|
||||
buf.append(decimalStyle.getDecimalSeparator());
|
||||
}
|
||||
// add leading zeros
|
||||
for (int i = 9 - stringSize; i > 0; i--) {
|
||||
buf.append(zero);
|
||||
int zeros = 9 - stringSize;
|
||||
if (zeros > 0) {
|
||||
buf.repeat(zero, zeros);
|
||||
}
|
||||
// truncate unwanted digits
|
||||
if (maxWidth < 9) {
|
||||
|
@ -3594,9 +3594,7 @@ public final class DateTimeFormatterBuilder {
|
|||
if (decimalPoint) {
|
||||
buf.append(decimalStyle.getDecimalSeparator());
|
||||
}
|
||||
for (int i = 0; i < minWidth; i++) {
|
||||
buf.append(decimalStyle.getZeroDigit());
|
||||
}
|
||||
buf.repeat(decimalStyle.getZeroDigit(), minWidth);
|
||||
}
|
||||
} else {
|
||||
int outputScale = Math.clamp(fraction.scale(), minWidth, maxWidth);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue