Example usage for java.text DateFormatSymbols setShortWeekdays

List of usage examples for java.text DateFormatSymbols setShortWeekdays

Introduction

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

Prototype

public void setShortWeekdays(String[] newShortWeekdays) 

Source Link

Document

Sets short weekday strings.

Usage

From source file:Main.java

public static void main(String[] args) {
    String[] newMonths = { "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC" };
    String[] newShortMonths = { "jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov",
            "dec" };
    String[] newWeekdays = { "", "Monday", "Tuesday", "Webnesday", "Thursday", "Friday", "Saturaday",
            "Sunday" };
    String[] shortWeekdays = { "", "monday", "tuesday", "webnesday", "thursday", "friday", "saturaday",
            "sunday" };

    DateFormatSymbols symbols = new DateFormatSymbols();
    symbols.setMonths(newMonths);//  w  w  w  . j  a  va2s  .c o  m
    symbols.setShortMonths(newShortMonths);
    symbols.setWeekdays(newWeekdays);
    symbols.setShortWeekdays(shortWeekdays);

    DateFormat format = new SimpleDateFormat("dd MMMM yyyy", symbols);
    System.out.println(format.format(new Date()));

    format = new SimpleDateFormat("dd MMM yyyy", symbols);
    System.out.println(format.format(new Date()));

    format = new SimpleDateFormat("EEEE, dd MMM yyyy", symbols);
    System.out.println(format.format(new Date()));

    format = new SimpleDateFormat("E, dd MMM yyyy", symbols);
    System.out.println(format.format(new Date()));
}

From source file:Main.java

public static void main(String[] args) {
    DateFormatSymbols symbols = new DateFormatSymbols(new Locale("en", "US"));
    String[] defaultDays = symbols.getShortWeekdays();

    for (int i = 0; i < defaultDays.length; i++) {
        System.out.print(defaultDays[i] + "  ");
    }/*from   w  w w.  j  ava2 s  .  co  m*/
    System.out.println();

    String[] capitalDays = { "", "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" };
    symbols.setShortWeekdays(capitalDays);

    String[] modifiedDays = symbols.getShortWeekdays();
    for (int i = 0; i < modifiedDays.length; i++) {
        System.out.println(modifiedDays[i] + "  ");
    }

    SimpleDateFormat formatter = new SimpleDateFormat("E", symbols);
    Date today = new Date();
    String result = formatter.format(today);
    System.out.println(result);

}

From source file:DateFormatSymbolsDemo.java

static public void changeWeekDays() {

    Date today;/*from   w ww  .  j a  va  2  s  .c  o  m*/
    String result;
    SimpleDateFormat formatter;
    DateFormatSymbols symbols;
    String[] defaultDays;
    String[] modifiedDays;

    symbols = new DateFormatSymbols(new Locale("en", "US"));
    defaultDays = symbols.getShortWeekdays();

    for (int i = 0; i < defaultDays.length; i++) {
        System.out.print(defaultDays[i] + "  ");
    }
    System.out.println();

    String[] capitalDays = { "", "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" };
    symbols.setShortWeekdays(capitalDays);

    modifiedDays = symbols.getShortWeekdays();
    for (int i = 0; i < modifiedDays.length; i++) {
        System.out.print(modifiedDays[i] + "  ");
    }

    System.out.println();
    System.out.println();

    formatter = new SimpleDateFormat("E", symbols);
    today = new Date();
    result = formatter.format(today);
    System.out.println(result);
}