RFR: JDK-8166138 - DateTimeFormatter.ISO_INSTANT should handle offsets

Roger Riggs roger.riggs at oracle.com
Wed Sep 19 19:18:22 UTC 2018


Hi Pallavi,

On 9/19/18 1:15 PM, Pallavi Sonal wrote:
> Hi,
>
> Please review the changes to the following issue:
>
> Bug : https://bugs.openjdk.java.net/browse/JDK-8166138
>
>   
>
> The proposed fix is located at:
>
> Webrev : http://cr.openjdk.java.net/~rpatil/8166138/webrev.00/
DateTimeFormatterBuilder.java: 3463+

It would be cleaner and not create any new objects to write a private 
method that
compared a string with a subSequence.  And the if statement would also 
be more readable.

If the text CharSequence is shorter than 3 or 5 or 6, I think you'll see 
an unexpected index exception.
That check could be built into the private method.

Since the if ... then ... else identifies exactly what string is in the 
input, it could use
only appendLiteral (instead of the pattern and appendOffset).
Then only appendLiteral would be needed and there would be fewer 
variables and conditions
in lines 3459-3470.

3478: the extra local variable isn't necessary if the (offsetPresent) 
?... expression were used in-line.

Thanks, Roger
>
>   
>
> As per ISO 8601 standards, an offset of zero, in addition to having the special representation "Z", can also be stated numerically as "+00:00", "+0000", or "+00" [1].  With this fix, Instant.parse() can parse a String containing the zero offsets in any of these three forms. Any other offset apart from "Z", "+00:00", "+0000", or "+00" will not be accepted in the input string to be parsed.
>
>   
>
> [1] https://en.wikipedia.org/wiki/ISO_8601
>
>   
>
> Thanks,
>
> Pallavi Sonal
>
>   
>
>   



More information about the core-libs-dev mailing list