LocalDate isSupported(TemporalField field) example

Description

LocalDate isSupported(TemporalField field) checks if the specified field is supported.

The supported fields are:

  • DAY_OF_WEEK
  • ALIGNED_DAY_OF_WEEK_IN_MONTH
  • ALIGNED_DAY_OF_WEEK_IN_YEAR
  • DAY_OF_MONTH
  • DAY_OF_YEAR
  • EPOCH_DAY
  • ALIGNED_WEEK_OF_MONTH
  • ALIGNED_WEEK_OF_YEAR
  • MONTH_OF_YEAR
  • PROLEPTIC_MONTH
  • YEAR_OF_ERA
  • YEAR
  • ERA

All other ChronoField instances will return false.

Syntax

isSupported has the following syntax.


public boolean isSupported(TemporalField field)

Example

The following example shows how to use isSupported.


import java.time.LocalDate;
import java.time.temporal.ChronoField;
/*  w  w  w . j  ava 2 s .c o  m*/
public class Main {
  public static void main(String[] args) {
    LocalDate a = LocalDate.of(2014, 6, 30);

    System.out.println(a.isSupported(ChronoField.DAY_OF_YEAR));
  }
}

The code above generates the following result.





















Home »
  Java Date Time »
    java.time Reference »




Clock
DayOfWeek
Duration
Instant
LocalDate
LocalDateTime
LocalTime
Month
MonthDay
OffsetDateTime
OffsetTime
Period
Year
YearMonth
ZonedDateTime
ZoneId
ZoneOffset