Java SimpleDateFormat .applyPattern (String pattern)

Syntax

SimpleDateFormat.applyPattern(String pattern) has the following syntax.

public void applyPattern(String pattern)

Example

In the following code shows how to use SimpleDateFormat.applyPattern(String pattern) method.


import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.Date;
//  w  w  w .j a v a2 s  .  com
public class Main {
  public static void main(String[] argv) throws Exception {

    SimpleDateFormat formatter = new SimpleDateFormat();
    formatter.applyPattern("MMM");
    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