Java Format - 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;
//w w  w  . j  a v  a  2s.c  o  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.