Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Java Arrays
  • Java Strings
  • Java OOPs
  • Java Collection
  • Java 8 Tutorial
  • Java Multithreading
  • Java Exception Handling
  • Java Programs
  • Java Project
  • Java Collections Interview
  • Java Interview Questions
  • Java MCQs
  • Spring
  • Spring MVC
  • Spring Boot
  • Hibernate
Open In App
Next Article:
Year isBefore() method in Java with Examples
Next article icon

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-

Next Article
Year isBefore() method in Java with Examples

B

barykrg
Improve
Article Tags :
  • Misc
  • Java
  • Java-Functions
  • Java-time package
  • Java-Year
Practice Tags :
  • Java
  • Misc

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
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences