--- old/src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java 2018-04-18 13:11:58.204351500 +0530 +++ new/src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java 2018-04-18 13:11:54.933697500 +0530 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2018, 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 @@ -638,24 +638,28 @@ if (active.valueParserIndex >= 0) { final int activeValueParser = active.valueParserIndex; - // adjacent parsing mode, update setting in previous parsers - NumberPrinterParser basePP = (NumberPrinterParser) active.printerParsers.get(activeValueParser); - if (pp.minWidth == pp.maxWidth && pp.signStyle == SignStyle.NOT_NEGATIVE) { + if(active.printerParsers.get(activeValueParser) instanceof PadPrinterParserDecorator) { + // The new Parser becomes the active parser + active.valueParserIndex = appendInternal(pp); + } else { + // adjacent parsing mode, update setting in previous parsers + NumberPrinterParser basePP = (NumberPrinterParser) active.printerParsers.get(activeValueParser); + if (pp.minWidth == pp.maxWidth && pp.signStyle == SignStyle.NOT_NEGATIVE) { // Append the width to the subsequentWidth of the active parser basePP = basePP.withSubsequentWidth(pp.maxWidth); // Append the new parser as a fixed width appendInternal(pp.withFixedWidth()); // Retain the previous active parser active.valueParserIndex = activeValueParser; - } else { - // Modify the active parser to be fixed width - basePP = basePP.withFixedWidth(); - // The new parser becomes the mew active parser - active.valueParserIndex = appendInternal(pp); - } - // Replace the modified parser with the updated one - active.printerParsers.set(activeValueParser, basePP); - } else { + } else { + // Modify the active parser to be fixed width + basePP = basePP.withFixedWidth(); + // The new parser becomes the mew active parser + active.valueParserIndex = appendInternal(pp); + } + // Replace the modified parser with the updated one + active.printerParsers.set(activeValueParser, basePP); + } } else { // The new Parser becomes the active parser active.valueParserIndex = appendInternal(pp); }