mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8262351: Extra '0' in java.util.Formatter for '%012a' conversion with a sign character
Reviewed-by: bchristi, naoto
This commit is contained in:
parent
c6d74bd933
commit
6971c23a3a
2 changed files with 56 additions and 2 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -3554,7 +3554,12 @@ public final class Formatter implements Closeable, Flushable {
|
|||
sb.append(upper ? "0X" : "0x");
|
||||
|
||||
if (f.contains(Flags.ZERO_PAD)) {
|
||||
trailingZeros(sb, width - s.length() - 2);
|
||||
int leadingCharacters = 2;
|
||||
if(f.contains(Flags.LEADING_SPACE) ||
|
||||
f.contains(Flags.PLUS) || neg) {
|
||||
leadingCharacters = 3;
|
||||
}
|
||||
trailingZeros(sb, width - s.length() - leadingCharacters);
|
||||
}
|
||||
|
||||
int idx = s.indexOf('p');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue