Java DateFormat MEDIUM

Syntax

DateFormat.MEDIUM has the following syntax.

public static final int MEDIUM

Example

In the following code shows how to use DateFormat.MEDIUM field.


import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;
//from   w  w w .ja  v a  2  s.co  m
public class Main {
  public static void main(String[] argv) throws Exception {

    Locale locale = Locale.ITALIAN;
    Date date = new Date();
    
    DateFormat df = DateFormat.getTimeInstance(DateFormat.MEDIUM, locale);

    String s = df.format(date);
    System.out.println(s);
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.text »




DateFormat
DecimalFormat
NumberFormat
SimpleDateFormat