< prev index next >
src/java.base/share/classes/java/time/format/DateTimeFormatter.java
Print this page
@@ -1683,10 +1683,12 @@
* @return a formatter based on this formatter with the requested resolver style, not null
*/
public DateTimeFormatter withResolverFields(TemporalField... resolverFields) {
Set<TemporalField> fields = null;
if (resolverFields != null) {
+ // An unmodifiable set wrapper is used instead of Set.of because resolverFields may
+ // contain null and Set.of is null-hostile.
fields = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(resolverFields)));
}
if (Objects.equals(this.resolverFields, fields)) {
return this;
}
< prev index next >