Java Format - Java DateFormat SHORT


DateFormat.SHORT has the following syntax.

public static final int SHORT


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

import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;
//from   w w  w.  j a  va  2s  .  c  om
public class Main {
  public static void main(String[] argv) throws Exception {

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

    String s = df.format(date);

The code above generates the following result.