The isTimeBased() method of ChronoField enum is used to check that if this ChronoField represents a component of a time or not.ChronoField constants from nano-of-second to am-pm-of-day are time-based.
Syntax:
public boolean isTimeBased()
Parameters: This method accepts nothing.
Return value: This method returns true if it is a component of a time.
Below programs illustrate the ChronoField.isTimeBased() method:
Program 1:
// Java program to demonstrate// ChronoField.isTimeBased() method import java.time.temporal.ChronoField; public class GFG { public static void main(String[] args) { // get chronoField ChronoField chronoField = ChronoField.valueOf("HOUR_OF_DAY"); // apply isTimeBased() boolean isTimeBasedAttribute = chronoField.isTimeBased(); // print System.out.println( "HOUR_OF_DAY" + " is Time based attribute:" + isTimeBasedAttribute); }} |
HOUR_OF_DAY is Time based attribute:true
Program 2:
// Java program to demonstrate// ChronoField.isTimeBased() method import java.time.temporal.ChronoField; public class GFG { public static void main(String[] args) { // get chronoField ChronoField chronoField = ChronoField.valueOf("YEAR_OF_ERA"); // apply isTimeBased() boolean isTimeBasedAttribute = chronoField.isTimeBased(); // print System.out.println("YEAR_OF_ERA" + " is Time based attribute:" + isTimeBasedAttribute); }} |
YEAR_OF_ERA is Time based attribute:false
References: https://docs.oracle.com/javase/10/docs/api/java/time/temporal/ChronoField.html#isTimeBased()

… [Trackback]
[…] Read More Info here to that Topic: geeksforgeeks.org/chronofield-istimebased-method-in-java-with-examples-2/ […]
… [Trackback]
[…] Read More Info here on that Topic: geeksforgeeks.org/chronofield-istimebased-method-in-java-with-examples-2/ […]
… [Trackback]
[…] Read More to that Topic: geeksforgeeks.org/chronofield-istimebased-method-in-java-with-examples-2/ […]
… [Trackback]
[…] Read More on that Topic: geeksforgeeks.org/chronofield-istimebased-method-in-java-with-examples-2/ […]