- java.time Package Classes
- java.time - Home
- java.time - Clock
- java.time - Duration
- java.time - Instant
- java.time - LocalDate
- java.time - LocalDateTime
- java.time - LocalTime
- java.time - MonthDay
- java.time - OffsetDateTime
- java.time - OffsetTime
- java.time - Period
- java.time - Year
- java.time - YearMonth
- java.time - ZonedDateTime
- java.time - ZoneId
- java.time - ZoneOffset
- java.time Package Enums
- java.time - Month
- java.time Useful Resources
- java.time - Discussion
java.time.LocalDateTime.isSupported() Method Example
Description
The java.time.LocalDateTime.isSupported(TemporalUnit unit) method checks if the specified unit is supported.
Declaration
Following is the declaration for java.time.LocalDateTime.isSupported(TemporalUnit unit) method.
public boolean isSupported(TemporalUnit unit)
Parameters
unit − the unit to check, null returns false.
Return Value
true if the unit is supported on this date, false if not.
Example
The following example shows the usage of java.time.LocalDateTime.isSupported(TemporalUnit unit) method.
package com.tutorialspoint; import java.time.LocalDateTime; import java.time.temporal.ChronoUnit; public class LocalDateTimeDemo { public static void main(String[] args) { LocalDateTime date = LocalDateTime.parse("2020-02-03T12:30:30"); System.out.println(date.isSupported(ChronoUnit.DAYS)); } }
Let us compile and run the above program, this will produce the following result −
true
Advertisements
To Continue Learning Please Login
Login with Google