import java.text.MessageFormat; import java.util.Date; public class FormaterDate { public static void main(String[] argv) throws Exception { Object[] data = new Object[] { new Date(), new Date(0) }; String msg = MessageFormat.format("La date du jour: {0} l''UTC est: {1}", data); System.out.println(msg); } } /* * Affichage: * La date du jour: 22/08/11 00:54 l'UTC est: 01/01/70 00:00 * */ |
A voir sur le mêm Sujet
-
Classe ‘MessageFormat’: Comment combiner la date avec des phrases
{filelink=5937} import java.text.MessageFormat; import java.util.Date; public class AffichageMois { public static void main(String[] argv) throws Exception { Object[] params = new Object[] { new Date()}; …
-
Classe ‘MessageFormat’: Afficher l’heure en format long (Exemple: 16:07:33 GMT)
{filelink=5933} import java.text.MessageFormat; import java.util.Date; public class HeureFormatLong { public static void main(String[] argv) throws Exception { Object[] params = new Object[] { new Date(), …
-
Java: Afficher la date en format complet à l’aide de MessageFormat
{filelink=5941} import java.text.MessageFormat; import java.util.Date; public class FormatComplet { public static void main(String[] argv) throws Exception { Object[] data = new Object[] { new Date()}; …
-
Classe ‘MessageFormat’: Utiliser un format personnalisé pour l’heure et la Date
{filelink=5935} import java.text.MessageFormat; import java.util.Date; public class HeureFormatPersonnel { public static void main(String[] argv) throws Exception { Object[] data = new Object[] { new Date(), …
-
Classe ‘MessageFormat’: Afficher l’heure en format court
{filelink=5931} 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(), …
-
Classe ‘MessageFormat’: Afficher l’heure en format complet(Ex: 12h30mn GMT)
{filelink=5934} import java.text.MessageFormat; import java.util.Date; public class HeureFormatComplet { public static void main(String[] argv) throws Exception { Object[] data = new Object[] { new Date(), …
-
Classe ‘MessageFormat’: Exemple de remplacement des ‘token’ dans une chaîne de caractère
{filelink=5923} import java.text.MessageFormat; public class ExempleMsgFormat { public static void main(String[] argv) { Object[] params = new Object[] { “Bienvenu”, “Paris”, “Berne”, “Londre” }; System.out.println(MessageFormat.format(“{0} …
-
Afficher la date en format moyen
{filelink=5939} import java.text.MessageFormat; import java.util.Date; public class FormatCourt { public static void main(String[] argv) throws Exception { Object[] data = new Object[] { new Date()}; …
-
Afficher la date en format long
{filelink=5940} import java.text.MessageFormat; import java.util.Date; public class FormatLong { public static void main(String[] argv) throws Exception { Object[] params = new Object[] { new Date() …
-
Classe ‘MessageFormat’: Exemple de Format pourcentage
{filelink=5929} import java.text.MessageFormat; public class FormatPoucentage { public static void main(String[] argv) throws Exception { Object[] data = new Object[] { new Double(123.45), new Double(123.56) …
-
Classe ‘MessageFormat’: Exemple de Format monétaire
{filelink=5928} import java.text.MessageFormat; public class FormatMonnaie { public static void main(String[] argv) throws Exception { Object[] data = new Object[] { new Double(250.50), new Double(650.15) …
-
Classe ‘MessageFormat’: Utilisation d’un formatage personnalisé
{filelink=5926} import java.text.MessageFormat; public class FormatagePersonnel { public static void main(String[] argv) throws Exception { Object[] params = new Object[] { new Integer(128), new Integer(255) …
-
Classe ‘MessageFormat’: Formater un Message qui contient un Nombre
{filelink=5924} import java.text.MessageFormat; public class ExempleMsgFormat2 { public static void main(String[] argv) throws Exception { Object[] params = new Object[] { new Integer(1939), new Integer(1945) …
-
MessageFormat: Formater un message
{filelink=5925} import java.text.MessageFormat; public class ExempleFomat { public static void main(String[] argv) throws Exception { Object[] params = new Object[] { “Fred”, “Jhon”, “Peter” }; …
-
MessageFormat: Formater un nombre à virgule
{filelink=5927} import java.text.MessageFormat; public class NombreVirgule { public static void main(String[] argv) throws Exception { Object[] params = new Object[] { new Double(3.14), new Double(1234.56) …
-
Java: Imprimer un Composant Texte
{filelink=924} import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.JButton; import java.awt.BorderLayout; import java.text.MessageFormat; import javax.swing.JFrame; import java.awt.event.*; public class ImprimerZoneDText { private static void imprimer(JTextArea …
-
Exemple d’affichage de date avec et sans formatage
{filelink=5539} import java.text.SimpleDateFormat; import java.util.Date; public class ExempleDateEtFormat { public static void main(String[] args) { Date dNow = new Date(); /* Afficher la date avec …
-
Affichage de date avec la méthode ‘printf’: Exemple d’utilisation de ‘%tC’ et ‘%tZ’
{filelink=6021} import java.util.Date; public class PrintfDate{ public static void main(String[] args) { System.out.printf(“La date %tCn”, new Date() ); System.out.printf(“La date %tz”, new Date()); } } …
-
Classe ‘DateFormat’: Afficher la date en format jj/mm/aa
{filelink=6016} import java.text.DateFormat; import java.util.Date; class DateFormatCourt { public static void main(String args[]) { Date date = new Date(); DateFormat fd = DateFormat.getDateInstance(DateFormat.SHORT); System.out.println(“Format Court …
-
Obtenir la date du jour avec la classe java.util.Date
{filelink=723} // Aujourd’hui System.out.println(new java.util.Date( ));
Cet article Classe ‘MessageFormat’: Exemple d’affichage de date est apparu en premier sur .