Example usage for java.text DateFormatSymbols getWeekdays

List of usage examples for java.text DateFormatSymbols getWeekdays

Introduction

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

Prototype

public String[] getWeekdays() 

Source Link

Document

Gets weekday strings.

Usage

From source file:MainClass.java

public static void main(String args[]) {
    DateFormatSymbols symbols = new DateFormatSymbols(Locale.FRENCH);
    String days[] = symbols.getWeekdays();
    for (int i = 0; i < days.length; i++) {
        System.out.println(days[i]);
    }//  w ww  .  jav  a2s .  c  o m

}

From source file:DaysOfTheWeek.java

public static void main(String argv[]) {
    Locale usersLocale = Locale.getDefault();

    DateFormatSymbols dfs = new DateFormatSymbols(usersLocale);
    String weekdays[] = dfs.getWeekdays();

    Calendar cal = Calendar.getInstance(usersLocale);

    int firstDayOfWeek = cal.getFirstDayOfWeek();
    int dayOfWeek;

    for (dayOfWeek = firstDayOfWeek; dayOfWeek < weekdays.length; dayOfWeek++)
        System.out.println(weekdays[dayOfWeek]);

    for (dayOfWeek = 0; dayOfWeek < firstDayOfWeek; dayOfWeek++)
        System.out.println(weekdays[dayOfWeek]);
}

From source file:MainClass.java

public static void main(String args[]) {
    JFrame f = new JFrame("JSpinner Sample");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    DateFormatSymbols symbols = new DateFormatSymbols(Locale.FRENCH);
    String days[] = symbols.getWeekdays();
    SpinnerModel model1 = new SpinnerListModel(days);
    SpinnerModel model2 = new SpinnerDateModel();
    JSpinner spinner1 = new JSpinner(model1);
    JSpinner spinner2 = new JSpinner(model2);
    f.add(spinner1, BorderLayout.NORTH);
    f.add(spinner2, BorderLayout.SOUTH);
    f.setSize(300, 100);//w w  w  .ja  va2 s. com
    f.setVisible(true);
}

From source file:SpinnerStringsSample.java

public static void main(String args[]) {
    JFrame frame = new JFrame("JSpinner Sample");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    DateFormatSymbols symbols = new DateFormatSymbols(Locale.FRENCH);

    String days[] = symbols.getWeekdays();
    SpinnerModel model1 = new SpinnerListModel(days);
    JSpinner spinner1 = new JSpinner(model1);

    JLabel label1 = new JLabel("French Days/List");
    JPanel panel1 = new JPanel(new BorderLayout());
    panel1.add(label1, BorderLayout.WEST);
    panel1.add(spinner1, BorderLayout.CENTER);
    frame.add(panel1, BorderLayout.NORTH);

    frame.setSize(200, 90);//from   w ww .j  a v  a2  s. c  o m
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String args[]) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    DateFormatSymbols symbols = new DateFormatSymbols(Locale.FRENCH);

    String days[] = symbols.getWeekdays();
    SpinnerModel model1 = new SpinnerListModel(days);
    JSpinner spinner1 = new JSpinner(model1);

    JLabel label1 = new JLabel("French Days/List");
    JPanel panel1 = new JPanel(new BorderLayout());
    panel1.add(label1, BorderLayout.WEST);
    panel1.add(spinner1, BorderLayout.CENTER);
    frame.add(panel1, BorderLayout.NORTH);

    frame.setSize(200, 90);/*from   ww w  .j  a v  a 2 s. c o m*/
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String args[]) {
    JFrame frame = new JFrame("JSpinner Sample");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    DateFormatSymbols symbols = new DateFormatSymbols(Locale.FRENCH);

    String days[] = symbols.getWeekdays();
    SpinnerModel model1 = new SpinnerListModel(days);
    JSpinner spinner1 = new JSpinner(model1);

    ChangeListener listener = new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            System.out.println("Source: " + e.getSource());
        }/*ww w. j  av  a  2 s .c  om*/
    };

    spinner1.addChangeListener(listener);

    JLabel label1 = new JLabel("French Days/List");
    JPanel panel1 = new JPanel(new BorderLayout());
    panel1.add(label1, BorderLayout.WEST);
    panel1.add(spinner1, BorderLayout.CENTER);
    frame.add(panel1, BorderLayout.NORTH);

    frame.setSize(200, 90);
    frame.setVisible(true);
}

From source file:org.alfresco.service.cmr.calendar.CalendarRecurrenceHelper.java

/**
 * Returns a lookup from recurrence rule days of the week, to
 *  the proper days of the week in the specified locale
 *///from www.j  a  v a  2s  .  c om
public static Map<String, String> buildLocalRecurrenceDaysOfTheWeek(Locale locale) {
    // Get our days of the week, in the current locale
    DateFormatSymbols dates = new DateFormatSymbols(I18NUtil.getLocale());
    String[] weekdays = dates.getWeekdays();

    // And map them based on the outlook two letter codes
    Map<String, String> days = new HashMap<String, String>();
    for (Map.Entry<String, Integer> e : DAY_NAMES_TO_CALENDAR_DAYS.entrySet()) {
        days.put(e.getKey(), weekdays[e.getValue()]);
    }
    return days;
}

From source file:com.qtplaf.library.util.Calendar.java

/**
 * Returns an array of localized names of week days.
 *
 * @return An array of names.//  w  w w.jav  a 2  s .c o  m
 * @param locale The desired locale.
 * @param capitalized A boolean to capitalize the name.
 */
public static String[] getLongDays(Locale locale, boolean capitalized) {

    DateFormatSymbols sysd = new DateFormatSymbols(locale);
    String[] dsc = sysd.getWeekdays();
    if (capitalized) {
        for (int i = 0; i < dsc.length; i++) {
            dsc[i] = StringUtils.capitalize(dsc[i]);
        }
    }
    return dsc;
}

From source file:com.application.utils.FastDateParser.java

private static String[] getDisplayNameArray(int field, boolean isLong, Locale locale) {
    DateFormatSymbols dfs = new DateFormatSymbols(locale);
    switch (field) {
    case Calendar.AM_PM:
        return dfs.getAmPmStrings();
    case Calendar.DAY_OF_WEEK:
        return isLong ? dfs.getWeekdays() : dfs.getShortWeekdays();
    case Calendar.ERA:
        return dfs.getEras();
    case Calendar.MONTH:
        return isLong ? dfs.getMonths() : dfs.getShortMonths();
    }/*from w ww  .ja v  a2s . c  o  m*/
    return null;
}

From source file:com.virtusa.akura.student.controller.StudentAttendenceController.java

/**
 * get all days without special holidays and Saturday,Sunday for given Date range. map key contains date
 * and value contains AttendeceStatus object with default values(as absent day)
 * /*ww  w  .  ja va 2  s.  c  o m*/
 * @param from from date
 * @param to to date
 * @return map
 * @throws AkuraAppException when exception occurs
 */
private Map<String, AttendeceStatus> getDaysWithoutHolydays(Date from, Date to) throws AkuraAppException {

    Calendar calFrom = Calendar.getInstance();
    Calendar calTo = Calendar.getInstance();

    calFrom.setTime(from);
    calTo.setTime(to);

    List<Holiday> holidayList = commonService.findHolidayByYear(from, to);

    Map<String, AttendeceStatus> allDaysBetween = new TreeMap<String, AttendeceStatus>();

    // to get name ex Sunday ,Monday ..
    DateFormatSymbols symbols = new DateFormatSymbols();
    String[] weekDays = symbols.getWeekdays();

    while (calFrom.before(calTo) || calFrom.equals(calTo)) {

        int dyaOfWeek = calFrom.get(Calendar.DAY_OF_WEEK);
        // remove weekends and special holidays
        if (dyaOfWeek != Calendar.SATURDAY && dyaOfWeek != Calendar.SUNDAY
                && !DateUtil.isHoliday(holidayList, calFrom.getTime())) {

            AttendeceStatus attSttus = new AttendeceStatus();
            attSttus.setDay(weekDays[dyaOfWeek]);
            allDaysBetween.put(DateUtil.getFormatDate(calFrom.getTime()), attSttus);
        }

        calFrom.set(Calendar.DATE, calFrom.get(Calendar.DATE) + 1);
    }

    return allDaysBetween;
}