Java SimpleDateFormat(String pattern, Locale locale) Constructor

Syntax

SimpleDateFormat(String pattern, Locale locale) constructor from SimpleDateFormat has the following syntax.

public SimpleDateFormat(String pattern,     Locale locale)

Example

In the following code shows how to use SimpleDateFormat.SimpleDateFormat(String pattern, Locale locale) constructor.


import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
//from   w  ww . j  a  va  2 s  . c  om
public class Main {
  public static void main(String[] argv) throws Exception {

    Locale locale = Locale.FRENCH;

    DateFormat formatter = new SimpleDateFormat("HH:mm:ss zzzz", locale);
    String s = formatter.format(new Date());
    System.out.println(s);

  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.text »




DateFormat
DecimalFormat
NumberFormat
SimpleDateFormat