Example usage for java.text DateFormatSymbols setEras

List of usage examples for java.text DateFormatSymbols setEras

Introduction

In this page you can find the example usage for java.text DateFormatSymbols setEras.

Prototype

public void setEras(String[] newEras) 

Source Link

Document

Sets era strings.

Usage

From source file:MainClass.java

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);// w  w  w. j a  va 2 s . co m

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

From source file:ChangeEra.java

public static void main(String s[]) {
    SimpleDateFormat sdf = new SimpleDateFormat();
    DateFormatSymbols dfs = sdf.getDateFormatSymbols();

    String era[] = { "BCE", "CE" };
    dfs.setEras(era);
    sdf.setDateFormatSymbols(dfs);//from w  ww  . j  a  v  a 2 s .co m

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