< prev index next >

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

Print this page

        

@@ -1683,10 +1683,11 @@
      * @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) {
+            // Set.of cannot be used because it is hostile to nulls and duplicate elements
             fields = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(resolverFields)));
         }
         if (Objects.equals(this.resolverFields, fields)) {
             return this;
         }
< prev index next >