List of usage examples for java.text DateFormatSymbols DateFormatSymbols
private DateFormatSymbols(boolean flag)
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]); }//from w w w . ja v a 2s.c om }
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 ww .j a v a2 s.c o 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: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);//from w w w .j av a 2s.c o m f.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 w w w. j av a 2s .co m*/ frame.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);/* w w w . ja v a 2 s. co 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()); }/* w ww .j a va 2s. c o m*/ }; 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:Main.java
/** * @return Get the array for week days for the current locale *///from ww w .j a va 2 s. c o m public static String[] getWeekDaysList(Context context) { DateFormatSymbols symbols = new DateFormatSymbols(getLocale(context)); return Arrays.copyOfRange(symbols.getShortWeekdays(), 1, 8); }
From source file:Main.java
public static String getDayAndMonthFromDateString(String date) { java.util.Calendar calendar = getCalendarFromStringDate(date); System.out.println("Date ->" + date); DateFormatSymbols symbols = new DateFormatSymbols(new Locale("es", "ES")); String[] monthNames = symbols.getMonths(); return calendar.get(java.util.Calendar.DAY_OF_MONTH) + " DE " + monthNames[calendar.get(java.util.Calendar.MONTH)]; }
From source file:Main.java
/** * Convert "Friday X Month Year" to "YYYY-MM-DD" * /* w w w.j a v a 2 s . c o m*/ * @param Date_STR * @param conf * @return */ public static String dateSTR2Num(String Date_STR, Configuration conf) { String[] DateARR = Date_STR.split(" "); String DayNo = DateARR[1]; String YearSTR = DateARR[3]; //----- Month problem ------ String MonthSTR = DateARR[2]; DateFormatSymbols symbols = new DateFormatSymbols(conf.locale); String[] monthNames = symbols.getMonths(); int iMonth = 0; for (int i = 0; i < monthNames.length; i++) if (MonthSTR.equals(monthNames[i])) iMonth = i; String MonthNo = Integer.toString(iMonth + 1); if (MonthNo.length() < 2) MonthNo = "0" + MonthNo; return YearSTR + "-" + MonthNo + "-" + DayNo; }