ChronoPeriod isNegative() method in Java with Examples Last Updated : 27 Jun, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report The isNegative() method of ChronoPeriod class in Java is used to check whether any of the three YEAR, MONTH, DAYS in period is negative or not. Syntax: boolean isNegative() Parameters: This method does not accepts any parameter. Return Value: This method returns True if any of the three-valued YEARs, MONTHS, DAYS for the given period is negative, else this will return false. Below programs illustrate the isNegative() method in Java: Program 1: Java // Java code to show the function isNegative() // to check whether any of the three given units // YEAR, MONTH, DAY is negative import java.time.*; import java.time.chrono.*; import java.time.temporal.ChronoUnit; public class ChronoPeriodDemo { // Function to check if any of the three // YEAR, MONTH, DAY is negative static void ifNegative(int year, int months, int days) { ChronoPeriod period = Period.of(year, months, days); System.out.println(period.isNegative()); } // Driver Code public static void main(String[] args) { int year = -12; int months = 3; int days = 31; ifNegative(year, months, days); } } Output: true Program 2: Java // Java code to show the function isNegative() // to check whether any of the three given units // YEAR, MONTH, DAY is negative import java.time.*; import java.time.chrono.*; import java.time.temporal.ChronoUnit; public class ChronoPeriodDemo { // Function to check if any of the three // YEAR, MONTH, DAY is negative static void ifNegative(int year, int months, int days) { ChronoPeriod period = Period.of(year, months, days); System.out.println(period.isNegative()); } // Driver Code public static void main(String[] args) { int year = 12; int months = 3; int days = 31; ifNegative(year, months, days); } } Output: false Reference: https://docs.oracle.com/javase/9/docs/api/java/time/chrono/ChronoPeriod.html#isNegative-- Comment More infoAdvertise with us Next Article ChronoPeriod isZero() method in Java with Examples S srinam Follow Improve Article Tags : Java Java-Functions Java-Time-Chrono package Java-ChronoPeriod Practice Tags : Java Similar Reads ChronoPeriod isZero() method in Java with Examples The isZero() method of ChronoPeriod class in Java is used to check whether all of the three YEAR, MONTH, DAYS in this period are zero. To check the zero periods, this function is used widely. A zero period is the period where all of the three YEAR, MONTHS and DAYS are zero. Syntax: boolean isZero() 2 min read Duration isNegative() method in Java with Examples The isNegative() method of Duration Class in java.time package is used to check if this duration is negative or not. It returns a boolean value depicting the same. Syntax: public boolean isNegative() Parameters: This method do not accepts any parameter. Return Value: This method returns a boolean va 1 min read ChronoPeriod equals() method in Java with Examples The equals() method of ChronoPeriod interface in Java is used to check if two given periods are equal or not. The comparison is based on the type ChronoPeriod and each of the three years, months and date. To be equal, all of the three years, month and date must be individually equal. Syntax: boolean 2 min read ChronoPeriod negated() method in Java with Examples The normalized() method of ChronoPeriod interface in Java is used to return a new instance of ChronoPeriod after normalizing years and months. Syntax: ChronoPeriod normalized() Parameters: This function does not accepts any parameter. Return Value: This function returns a new instance of ChronoPerio 2 min read ChronoPeriod negated() method in Java with Examples The negated() method of ChronoPeriod interface in Java is used to return a new instance of ChronoPeriod after negating all the elements of the period YEAR, MONTH, DAY. Syntax: ChronoPeriod negated() Parameters: This method does not accepts any parameter. Return Value: This method returns a new insta 2 min read Period isNegative() method in Java with Examples The isNegative() method of Period class in Java is used to check whether any of the three YEAR, MONTH, DAYS in period is negative or not. Syntax: public boolean isNegative() Parameters: This method does not accepts any parameter. Return Value: This method returns True if any of the three valued YEAR 2 min read Like