Java Format - Java DateFormat .getDateTimeInstance ()








Syntax

DateFormat.getDateTimeInstance() has the following syntax.

public static final DateFormat getDateTimeInstance()

Example

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

import java.text.DateFormat;
import java.util.Date;
/*from w  w  w  . j av  a  2  s .c  om*/
public class Main {
  public static void main(String[] argv) throws Exception {
    DateFormat dateFormat = DateFormat.getDateTimeInstance();
    
    
    String s = dateFormat.format(new Date());
    System.out.println(s);

  }
}

The code above generates the following result.