Afficher l’heure format 12 Heures: AM ou PM

Author:


Download

import java.util.Calendar;
import java.util.Formatter;
 
public class HeureAmPm {
  public static void main(String[] argv) throws Exception {
    Formatter fmt = new Formatter();
    Calendar cal = Calendar.getInstance();
 
    // Affichage l'heure en 12 heures.
    fmt.format("L'heure: %tr", cal);
    System.out.println(fmt);
 
  }
}
/* Sortie
 * L'heure: 09:35:55 PM
 **/