Exemple de méthode java.time.YearMonth.isBefore ()

La description

le java.time.YearMonth.isBefore(YearMonth other) La méthode vérifie si cette année-mois est antérieure à l'année-mois spécifiée.

Déclaration

Voici la déclaration pour java.time.YearMonth.isBefore(YearMonth other) méthode.

public boolean isBefore(YearMonth other)

Paramètres

other - l'autre année-mois à comparer, non nul.

Valeur de retour

true si cette année-mois est antérieure à l'année-mois spécifiée.

Exemple

L'exemple suivant montre l'utilisation de la méthode java.time.YearMonth.isBefore (YearMonth other).

package com.tutorialspoint;

import java.time.YearMonth;

public class YearMonthDemo {
   public static void main(String[] args) {
 
      YearMonth date = YearMonth.of(2016,11);
      YearMonth date1 = YearMonth.of(2017,12);
      System.out.println(date1.isBefore(date));  
   }
}

Compilons et exécutons le programme ci-dessus, cela produira le résultat suivant -

false