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 * * */
A voir sur le même Sujet
-
Afficher la date en format court avec le nom du mois
{filelink=5599} import java.text.Format; import java.text.SimpleDateFormat; import java.util.Date; public class DateCourte { public static void main(String[] argv) throws Exception { Format format = new SimpleDateFormat(“EEE, dd …
-
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(), …
-
Afficher la Date en format court(jj/mm/aa)
{filelink=5773} import java.util.Calendar; import java.util.Formatter; public class DateFormat { public static void main(String[] argv) throws Exception { Formatter fmt = new Formatter(); Calendar cal = …
-
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} …
-
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’: 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) …
-
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() …