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 Duration isNegative() 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 plus() method in Java with Examples The plus() method of ChronoPeriod interface in Java is used to add the given amount of period to the specified period. This function operates separately on YEAR, MONTH and DAY. Note: Normalization is not performed. 12 months and 1 year are different. Syntax: ChronoPeriod plus(TemporalAmount amountTo 2 min read ChronoLocalDate isAfter() method in Java with Examples The isAfter() method of ChronoLocalDate interface in Java checks if this date is after the specified date and returns a boolean value stating the same. Syntax: public boolean isAfter(ChronoLocalDate date2) Parameter: This method accept a single mandatory parameter date2 the other date to compare to 1 min read ChronoPeriod minus() method in Java with Examples The minus() method of ChronoPeriod class in Java is used to subtract the given amount of period from the specified period. This function operates separately on YEAR, MONTH and DAY. Note: Normalization is not performed. 12 months and 1 year are different. Syntax: ChronoPeriod minus(TemporalAmount amo 2 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 Like