Classe ‘Calendar’: Afficher la date et l’heure en même temps

Author:


{filelink=5576}


import java.util.Calendar;

public class DateHeure {

  public static void main(String[] args) {
    Calendar now = Calendar.getInstance();

    System.out.println("Date complete : " + (now.get(Calendar.DATE) + 1) + "-"
        + now.get(Calendar.MONTH) + "-" + now.get(Calendar.YEAR) + " "
        + now.get(Calendar.HOUR_OF_DAY) + ":" + now.get(Calendar.MINUTE) + ":"
        + now.get(Calendar.SECOND) + "." + now.get(Calendar.MILLISECOND));
  }
}

Leave a Reply

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