ChronoUnit isDurationEstimated() method in Java with Examples
Last Updated :
29 Jan, 2020
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:
import java.time.temporal.ChronoUnit;
public class GFG {
public static void main(String[] args)
{
ChronoUnit chronoUnit
= ChronoUnit.valueOf( "NANOS" );
boolean isDurationEstimatedAttribute
= chronoUnit.isDurationEstimated();
System.out.println(
"NANOS"
+ " is Duration Estimated attribute:"
+ isDurationEstimatedAttribute);
}
}
|
Output:
NANOS is Duration Estimated attribute:false
Program 2:
import java.time.temporal.ChronoUnit;
public class GFG {
public static void main(String[] args)
{
ChronoUnit chronoUnit
= ChronoUnit.valueOf( "DAYS" );
boolean isDurationEstimatedAttribute
= chronoUnit.isDurationEstimated();
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()
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...