ERROR - The method appendValue(TemporalField) in the type DateTimeFormatterBuilder is not applicable for the arguments ()

Error

The method appendValue(TemporalField) in the type DateTimeFormatterBuilder is not applicable for the arguments ()

Error Type

Compile Time

Sample Code

DateTimeFormatter formatter = builder.appendLiteral("Day is:")
                                                                                .appendValue(1).toFormatter();


Cause

appendValue method of DateTimeFormatter expects a TemporalField.

Resolution

Provide a TemporalField instance as argument to appendValue

DateTimeFormatter formatter = builder.appendLiteral("Day is:")
                                                          .appendValue(
ChronoField.MONTH_OF_YEAR).toFormatter();

* ChronoField implement TemporalField and hence its acceptable.