Format Date() in long : Message Format « I18N « Java Tutorial

Home
Java Tutorial
1.Language
2.Data Type
3.Operators
4.Statement Control
5.Class Definition
6.Development
7.Reflection
8.Regular Expressions
9.Collections
10.Thread
11.File
12.Generics
13.I18N
14.Swing
15.Swing Event
16.2D Graphics
17.SWT
18.SWT 2D Graphics
19.Network
20.Database
21.Hibernate
22.JPA
23.JSP
24.JSTL
25.Servlet
26.Web Services SOA
27.EJB3
28.Spring
29.PDF
30.Email
31.J2ME
32.J2EE Application
33.XML
34.Design Pattern
35.Log
36.Security
37.Apache Common
38.Ant
39.JUnit
Java Tutorial » I18N » Message Format 
13.12.13.Format Date() in longPrevious/Next
import java.text.MessageFormat;
import java.util.Date;

public class Main {
  public static void main(String[] argvthrows Exception {
    Object[] params = new Object[] { new Date()new Date(0) };
    String msg = MessageFormat.format("{0,time,long} and UTC of 0 is {1,time,long}", params);

    System.out.println(msg);
  }
}
//8:31:27 PDT AM and UTC of 0 is 4:00:00 PST PM
13.12.Message Format
13.12.1.Use MessageFormat to format a sentence
13.12.2.Date Number Sample
13.12.3.Substitute tokens in a String
13.12.4.Formatting a Message Containing a Number
13.12.5.Format message with Integer fillers
13.12.6.Use a custom format
13.12.7.Floating point numbers
13.12.8.Currency number format
13.12.9.Percent value format
13.12.10.Formatting a Message Containing a Time
13.12.11.Format Date() in short format
13.12.12.Format Date() value in medium format
13.12.13.Format Date() in long
13.12.14.Format Date value in full length
13.12.15.Use a custom format for Date value
13.12.16.Formatting a Message Containing a Date
13.12.17.Combine date value in a sentence
13.12.18.Set MessageFormat to Locale.US
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.