SimpleDateFormat: applyPattern(String pattern) : SimpleDateFormat « java.text « Java by API






SimpleDateFormat: applyPattern(String pattern)

 
import java.text.DateFormatSymbols;
import java.text.SimpleDateFormat;
import java.util.Date;

public class MainClass {
  public static void main(String args[]) throws Exception {
    SimpleDateFormat sdf = new SimpleDateFormat();
    DateFormatSymbols dfs = sdf.getDateFormatSymbols();

    String era[] = { "BCE", "CE" };
    dfs.setEras(era);
    sdf.setDateFormatSymbols(dfs);

    sdf.applyPattern("MMMM d yyyy G");
    System.out.println(sdf.format(new Date()));
  }
}


           
         
  








Related examples in the same category

1.new SimpleDateFormat('hh:mm:ss')
2.new SimpleDateFormat('dd MMM yyyy hh:mm:ss zzz')
3.new SimpleDateFormat('E MMM dd yyyy')
4.new SimpleDateFormat('yyyy-MM-dd')
5.new SimpleDateFormat(String pattern, Locale locale)
6.SimpleDateFormat: format(Date d)
7.SimpleDateFormat: parse(String text, ParsePosition pos)
8.SimpleDateFormat: setDateFormatSymbols(DateFormatSymbols newFormatSymbols)