Java DateFormat .getTimeInstance (int style)

Syntax

DateFormat.getTimeInstance(int style) has the following syntax.

public static final DateFormat getTimeInstance(int style)

Example

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


import java.text.DateFormat;
import java.util.Date;
/*ww  w  . j  a v a 2s  . c  o m*/
public class Main {
  public static void main(String[] argv) throws Exception {
    DateFormat dateFormat = DateFormat.getTimeInstance(DateFormat.LONG);
    
    
    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