8167618: DateTimeFormatter.format() uses exceptions for flow control

Removed flow control in exception catch

Reviewed-by: rriggs, scolebourne
This commit is contained in:
Anubhav Meena 2016-11-17 11:55:59 +00:00
parent 5b06ce3c07
commit 3f35be7242

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2016, 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
@ -302,14 +302,10 @@ final class DateTimePrintContext {
* @throws DateTimeException if the field is not available and the section is not optional
*/
Long getValue(TemporalField field) {
try {
return temporal.getLong(field);
} catch (DateTimeException ex) {
if (optional > 0) {
return null;
}
throw ex;
if (optional > 0 && !temporal.isSupported(field)) {
return null;
}
return temporal.getLong(field);
}
//-----------------------------------------------------------------------