Ajuster la date à l’aide de la classe ‘Calendar’

Author:


{filelink=5573}


import java.util.Calendar;

public class AjustDate {

  public static void main(String[] args) {
    Calendar maintenant = Calendar.getInstance();
    System.out.println("Date Actuelle : " + (maintenant.get(Calendar.DATE) + 1) + "-"
        + maintenant.get(Calendar.MONTH) + "-" + maintenant.get(Calendar.YEAR));
    System.out.println("Heure actuelle: " + maintenant.get(Calendar.HOUR_OF_DAY) + ":"
        + maintenant.get(Calendar.MINUTE) + ":" + maintenant.get(Calendar.SECOND));

   System.out.println("Dans 12 heures : " + (maintenant.get(Calendar.DATE) + 1) + "-"
       + maintenant.get(Calendar.MONTH) + "-" + maintenant.get(Calendar.YEAR));  }
}

Leave a Reply

Your email address will not be published. Required fields are marked *