Thursday, February 19, 2026
HomeLanguagesJavaLocalTime isSupported() method in Java with Examples

LocalTime isSupported() method in Java with Examples

In LocalTime class, there are two types of isSupported() method depending upon the parameters passed to it.

isSupported(TemporalField field)

isSupported() method of a LocalTime class used to Check if the specified field is supported by LocalTime class or not means using this method we can check if this LocalTime can be queried for the specified field.
The supported fields of ChronoField are: 
 

  • NANO_OF_SECOND
  • MICRO_OF_SECOND
  • MILLI_OF_SECOND
  • INSTANT_SECONDS
  • SECOND_OF_MINUTE
  • NANO_OF_DAY
  • MICRO_OF_DAY
  • MILLI_OF_DAY
  • SECOND_OF_DAY
  • MINUTE_OF_HOUR
  • MINUTE_OF_DAY
  • HOUR_OF_AMPM
  • CLOCK_HOUR_OF_AMPM
  • HOUR_OF_DAY
  • CLOCK_HOUR_OF_DAY
  • AMPM_OF_DAY

All other ChronoField instances will return false.
Syntax: 

public boolean isSupported(TemporalField field)

Parameters: This method accepts one single parameter field which is the field to check.
Return value: This method returns boolean value true if the field is supported on this LocalTime, false if not.
Below programs illustrate the isSupported() method:
Program 1: 
 

Java




// Java program to demonstrate
// LocalTime.isSupported() method
 
import java.time.*;
import java.time.temporal.ChronoField;
 
public class GFG {
    public static void main(String[] args)
    {
 
        // create a LocalTime object
        LocalTime lt
            = LocalTime.parse("19:34:50.63");
 
        // check Milli of Second is supported in LocalTime
        boolean value
            = lt.isSupported(ChronoField.MILLI_OF_SECOND);
 
        // print result
        System.out.println("MilliSecond Field is supported: "
                           + value);
    }
}


Output

MilliSecond Field is supported: true

isSupported(TemporalUnit unit)

isSupported() method of a LocalTime class used to Check if the specified unit is supported by LocalTime class or not means using this method we can check if this LocalTime can be queried for the specified unit.
The supported fields of ChronoUnit are: 
 

  • NANOS
  • MICROS
  • MILLIS
  • SECONDS
  • MINUTES
  • HOURS
  • HALF_DAYS

All other ChronoUnit instances will return false.
Syntax: 

public boolean isSupported(TemporalUnit unit)

Parameters: This method accepts one single parameter unit which is the unit to check.
Return value: This method returns boolean value true if the field is supported on this LocalTime, false if not.
Below programs illustrate the isSupported() method:
Program 1: 
 

Java




// Java program to demonstrate
// LocalTime.isSupported() method
 
import java.time.*;
import java.time.temporal.ChronoUnit;
 
public class GFG {
    public static void main(String[] args)
    {
 
        // create a LocalTime object
        LocalTime lt
            = LocalTime.parse("19:34:50.63");
 
        // check MILLIS ChronoUnit supported in LocalTime
        boolean value
            = lt.isSupported(ChronoUnit.MILLIS);
 
        // print result
        System.out.println("ChronoUnit MILLIS is  supported: "
                           + value);
    }
}


Output: 

ChronoUnit MILLIS is  supported: true

 

Reference: 

 

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32506 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6882 POSTS0 COMMENTS
Nicole Veronica
12005 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12099 POSTS0 COMMENTS
Shaida Kate Naidoo
7011 POSTS0 COMMENTS
Ted Musemwa
7255 POSTS0 COMMENTS
Thapelo Manthata
6967 POSTS0 COMMENTS
Umr Jansen
6956 POSTS0 COMMENTS