Java DateFormat.getDateInstance()

Syntax

DateFormat.getDateInstance() has the following syntax.

public static final DateFormat getDateInstance()

Example

In the following code shows how to use DateFormat.getDateInstance() method.


import java.text.DateFormat;
import java.util.Date;
//w w w .jav a 2 s  .  co m
public class Main {
  public static void main(String[] argv) throws Exception {
    DateFormat dateFormat = DateFormat.getDateInstance();
    
    
    String s = dateFormat.format(new Date());
    System.out.println(s);

  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.text »




DateFormat
DecimalFormat
NumberFormat
SimpleDateFormat