Classe ‘MessageFormat’: Afficher l’heure en format court

Author:


Download

 
import java.text.MessageFormat;
import java.util.Date;
 
public class HeureFormatCourt {
  public static void main(String[] argv) throws Exception {
    Object[] data = new Object[] { new Date(), new Date(0) };
    String msg = MessageFormat.format("Heure Format Court:{0,time,short} l''UTC {1,time,short}", data);
    System.out.println(msg);
  }
}
/* Affichage:
 * Heure Format Court:00:34 l'UTC 00:00
 *
 *
 */