< prev index next >

src/java.base/share/classes/java/time/format/DateTimePrintContext.java

Print this page

        

*** 300,316 **** * @param field the field to find, not null * @return the value, null if not found and optional is true * @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; } } //----------------------------------------------------------------------- /** --- 300,313 ---- * @param field the field to find, not null * @return the value, null if not found and optional is true * @throws DateTimeException if the field is not available and the section is not optional */ Long getValue(TemporalField field) { ! if (optional == 0) { return temporal.getLong(field); ! } else { ! return temporal.isSupported(field) ? temporal.getLong(field) : null; } } //----------------------------------------------------------------------- /**
< prev index next >