Java Format - Java DateFormat.getTimeInstance()


DateFormat.getTimeInstance() has the following syntax.

public static final DateFormat getTimeInstance()


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

/*w  w w . ja  va  2  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.getTimeInstance();
    String s = dateFormat.format(new Date());


The code above generates the following result.