--- old/src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java 2018-09-21 15:14:47.391943300 +0530 +++ new/src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java 2018-09-21 15:14:43.361881400 +0530 @@ -821,6 +821,7 @@ * With this method, formatting nano-of-second outputs zero, three, six * or nine digits as necessary. * The localized decimal style is not used. + * During parsing, any offset if available is accepted. *

* The instant is obtained using {@link ChronoField#INSTANT_SECONDS INSTANT_SECONDS} * and optionally {@code NANO_OF_SECOND}. The value of {@code INSTANT_SECONDS} @@ -3462,7 +3463,7 @@ .appendValue(MINUTE_OF_HOUR, 2).appendLiteral(':') .appendValue(SECOND_OF_MINUTE, 2) .appendFraction(NANO_OF_SECOND, minDigits, maxDigits, true) - .appendLiteral('Z') + .appendOffsetId() .toFormatter().toPrinterParser(false); DateTimeParseContext newContext = context.copy(); int pos = parser.parse(newContext, text, position); @@ -3480,6 +3481,7 @@ Long nanoVal = newContext.getParsed(NANO_OF_SECOND); int sec = (secVal != null ? secVal.intValue() : 0); int nano = (nanoVal != null ? nanoVal.intValue() : 0); + int offset = newContext.getParsed(OFFSET_SECONDS).intValue(); int days = 0; if (hour == 24 && min == 0 && sec == 0 && nano == 0) { hour = 0; @@ -3492,7 +3494,7 @@ long instantSecs; try { LocalDateTime ldt = LocalDateTime.of(year, month, day, hour, min, sec, 0).plusDays(days); - instantSecs = ldt.toEpochSecond(ZoneOffset.UTC); + instantSecs = ldt.toEpochSecond(ZoneOffset.ofTotalSeconds(offset)); instantSecs += Math.multiplyExact(yearParsed / 10_000L, SECONDS_PER_10000_YEARS); } catch (RuntimeException ex) { return ~position;