Java Format - Java DateFormat.getInstance()








Syntax

DateFormat.getInstance() has the following syntax.

public static final DateFormat getInstance()

Example

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

//from w w w.  j a  v  a2 s  .  c  o  m
import java.text.DateFormat;
import java.util.Date;

public class Main {
  public static void main(String[] argv) throws Exception {
    DateFormat dateFormat = DateFormat.getInstance();
    
    
    String s = dateFormat.format(new Date());
    System.out.println(s);

  }
}

The code above generates the following result.