Format date in Short format in Java

Description

The following code shows how to format date in Short format.

Example


// w  ww  . j  a  v a  2s .  c  o  m
import java.text.DateFormat;

import java.util.Date;

public class Main {
  public static void main(String[] args) {
    Date date = new Date();
    String strDate = DateFormat.getDateInstance(DateFormat.SHORT).format(date);

    System.out.println(strDate);
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    Date »




Date Get
Date Set
Date Format
Date Compare
Date Convert
Date Calculation
Date Parse
Timezone