Year isBefore() method in Java with Examples Last Updated : 27 Nov, 2018 Comments Improve Suggest changes Like Article Like Report The isBefore() method of Year class in Java is used to check if this current Year object is before the Year specified as parameter to this method. Syntax: public boolean isBefore(Year otherYear) Parameter: It accepts a single parameter otherYear with which the current Year object is to be compared. Return Value: It returns a boolean True value if this Year object's value is before the value of Year object specified as a parameter to the method, otherwise it returns False. Below programs illustrate the isBefore() method of Year in Java: Program 1: Java // Program to illustrate the isBefore() method import java.util.*; import java.time.*; public class GfG { public static void main(String[] args) { // Create first Year object Year firstYear = Year.of(2018); // Create second Year object Year secondYear = Year.of(1997); // Check if this year object's value is // before the specified Year or not System.out.println(firstYear.isBefore(secondYear)); } } Output: false Program 2: Java // Program to illustrate the isBefore() method import java.util.*; import java.time.*; public class GfG { public static void main(String[] args) { // Create first Year object Year firstYear = Year.of(1997); // Create second Year object Year secondYear = Year.of(2018); // Check if this year object's value is // before the specified Year or not System.out.println(firstYear.isBefore(secondYear)); } } Output: true Reference: https://docs.oracle.com/javase/8/docs/api/java/time/Year.html#isBefore-java.time.Year- Comment More infoAdvertise with us Next Article Year isBefore() method in Java with Examples B barykrg Follow Improve Article Tags : Misc Java Java-Functions Java-time package Java-Year +1 More Practice Tags : JavaMisc Similar Reads YearMonth isBefore() method in Java with Examples The isBefore() method of Year class in Java is used to check if this current YearMonth object is before the YearMonth specified as parameter to this method. Syntax: public boolean isBefore(Year otherYearMonth) Parameter: It accepts a single parameter otherYearMonth with which the current YearMonth o 2 min read Year isAfter() method in Java with Examples The isAfter() method of Year class in Java is used to check if this current Year object is after the Year specified as parameter to this method. Syntax: public boolean isAfter(Year otherYear) Parameter: It accepts a single parameter otherYear with which the current Year object is to be compared. Ret 2 min read Year isLeap() method in Java with Examples The isLeap() method of Year class in Java is used to check if this Year object is a leap year or not according to the proleptic calendar system rules. A year is a leap year if it has 366 days in it. According to the proleptic calendar system rules, a year is a Leap year if: If it is divisible by 4. 2 min read YearMonth isAfter() method in Java with Examples The isAfter() method of Year class in Java is used to check if this current YearMonth object is after the YearMonth specified as parameter to this method. Syntax: public boolean isAfter(Year otherYearMonth) Parameter: It accepts a single parameter otherYearMonth with which the current YearMonth obje 2 min read Instant isBefore() method in Java with Examples isBefore() method of an Instant class checks if this instant timeline position is before the instant passed as parameter or not. If this instant timeline position is before the instant passed as a parameter then the method will return true else false. The comparison is based on the time-line positio 2 min read Like