Friday, December 12, 2025
HomeLanguagesJavaChronoUnit isDurationEstimated() method in Java with Examples

ChronoUnit isDurationEstimated() method in Java with Examples

The isDurationEstimated() method of ChronoUnit enum is used to check if the duration of the ChronoUnit is an estimate. All the time units in this ChronoUnit are considered to be accurate, while all date units in this ChronoUnit are considered to be estimated.

Syntax:

public boolean isDurationEstimated()

Parameters: This method accepts nothing.

Return value: This method returns true if the duration is estimated, false if accurate.

Below programs illustrate the ChronoUnit.isDurationEstimated() method:
Program 1:




// Java program to demonstrate
// ChronoUnit.isDurationEstimated() method
  
import java.time.temporal.ChronoUnit;
  
public class GFG {
    public static void main(String[] args)
    {
  
        // get ChronoUnit
        ChronoUnit chronoUnit
            = ChronoUnit.valueOf("NANOS");
  
        // apply isDurationEstimated()
        boolean isDurationEstimatedAttribute
            = chronoUnit.isDurationEstimated();
  
        // print
        System.out.println(
            "NANOS"
            + " is Duration Estimated attribute:"
            + isDurationEstimatedAttribute);
    }
}


Output:

NANOS is Duration Estimated attribute:false

Program 2:




// Java program to demonstrate
// ChronoUnit.isDurationEstimated() method
  
import java.time.temporal.ChronoUnit;
  
public class GFG {
    public static void main(String[] args)
    {
  
        // get ChronoUnit
        ChronoUnit chronoUnit
            = ChronoUnit.valueOf("DAYS");
  
        // apply isDurationEstimated()
        boolean isDurationEstimatedAttribute
            = chronoUnit.isDurationEstimated();
  
        // print
        System.out.println(
            "DAYS"
            + " is Duration Estimated attribute:"
            + isDurationEstimatedAttribute);
    }
}


Output:

DAYS is Duration Estimated attribute:true

References: https://docs.oracle.com/javase/10/docs/api/java/time/temporal/ChronoUnit.html#isDurationEstimated()

RELATED ARTICLES

1 COMMENT

Most Popular

Dominic
32445 POSTS0 COMMENTS
Milvus
105 POSTS0 COMMENTS
Nango Kala
6814 POSTS0 COMMENTS
Nicole Veronica
11952 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12029 POSTS0 COMMENTS
Shaida Kate Naidoo
6949 POSTS0 COMMENTS
Ted Musemwa
7199 POSTS0 COMMENTS
Thapelo Manthata
6895 POSTS0 COMMENTS
Umr Jansen
6882 POSTS0 COMMENTS