List of usage examples for java.text DateFormatSymbols getShortWeekdays
public String[] getShortWeekdays()
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] + " "); }/* w w w. j ava2s . 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:Main.java
public static String getDayOfTheWeek(int dayOfTheWeek) { DateFormatSymbols symbols = new DateFormatSymbols(); String[] dayNames = symbols.getShortWeekdays(); return dayNames[dayOfTheWeek]; }
From source file:Main.java
/** * @return Get the array for week days for the current locale *//* www. j a v a 2 s. co 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
/** ExpCalendarUtil.java * The number to Week/* www.j av a 2 s.c om*/ * @param number - Number day of Week (on the code Sunday is equal 7) * @return [String] - abbreviated name of the days of the week */ public static String number2Week(int number) { if (number < 1 || number > 7) return null; //Day of Week 1-7 if (number == 7) { number = 1; } else { number = number + 1; } final DateFormatSymbols symbols = new DateFormatSymbols(); //use user locale final String nameDayOfWeek = symbols.getShortWeekdays()[number]; //Short name or getWeekdays for complete name return nameDayOfWeek.toUpperCase(); //name to uppercase }
From source file:DateFormatSymbolsDemo.java
static public void changeWeekDays() { Date today;//w w w. jav a 2 s .c om 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); }
From source file:com.autentia.jsf.component.ocupation.HtmlOcupationCalendarRenderer.java
private static String[] mapShortWeekdays(DateFormatSymbols symbols) { String[] weekdays = new String[7]; String[] localeWeekdays = symbols.getShortWeekdays(); weekdays[0] = localeWeekdays[Calendar.MONDAY]; weekdays[1] = localeWeekdays[Calendar.TUESDAY]; weekdays[2] = localeWeekdays[Calendar.WEDNESDAY]; weekdays[3] = localeWeekdays[Calendar.THURSDAY]; weekdays[4] = localeWeekdays[Calendar.FRIDAY]; weekdays[5] = localeWeekdays[Calendar.SATURDAY]; weekdays[6] = localeWeekdays[Calendar.SUNDAY]; return weekdays; }
From source file:com.qtplaf.library.util.Calendar.java
/** * Returns an array of localized names of week days. * * @return An array of names./* w ww .j a v a2 s .c om*/ * @param locale The desired locale. * @param capitalized A boolean to capitalize the name. */ public static String[] getShortDays(Locale locale, boolean capitalized) { DateFormatSymbols sysd = new DateFormatSymbols(locale); String[] dsc = sysd.getShortWeekdays(); 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(); }/* w w w.ja v a 2 s . c om*/ return null; }
From source file:de.hybris.platform.commercefacades.storelocator.converters.populator.OpeningDayPopulator.java
/** * Assumption order is not a locale related ,removes an empty entries * //from w w w . j a v a2 s .com **/ protected List<String> getWeekDaySymbols() { final List<String> notEmptyWeekDay = new ArrayList<String>(); final DateFormatSymbols weekDaySymbols = new DateFormatSymbols(getCurrentLocale()); for (final String anyWeekDay : weekDaySymbols.getShortWeekdays()) { if (StringUtils.isNotBlank(anyWeekDay)) { notEmptyWeekDay.add(anyWeekDay); } } return notEmptyWeekDay; }
From source file:JapaneseCalendar.java
public void paintComponent(Graphics g) { int width = 400; int height = 400; Calendar cal = Calendar.getInstance(locale); cal.setTime(new Date()); String header = cal.getDisplayName(Calendar.MONTH, Calendar.LONG, locale); header += " " + cal.get(Calendar.YEAR); FontMetrics fm = g.getFontMetrics(); Insets insets = getInsets();//from w w w. ja v a 2 s .c o m g.setColor(Color.black); g.drawString(header, (width - fm.stringWidth(header)) / 2, insets.top + fm.getHeight()); DateFormatSymbols dfs = new DateFormatSymbols(locale); String[] weekdayNames = dfs.getShortWeekdays(); int fieldWidth = (width - insets.left - insets.right) / 7; g.drawString(weekdayNames[Calendar.SUNDAY], insets.left + (fieldWidth - fm.stringWidth(weekdayNames[Calendar.SUNDAY])) / 2, insets.top + 3 * fm.getHeight()); g.drawString(weekdayNames[Calendar.MONDAY], insets.left + fieldWidth + (fieldWidth - fm.stringWidth(weekdayNames[Calendar.MONDAY])) / 2, insets.top + 3 * fm.getHeight()); g.drawString(weekdayNames[Calendar.TUESDAY], insets.left + 2 * fieldWidth + (fieldWidth - fm.stringWidth(weekdayNames[Calendar.TUESDAY])) / 2, insets.top + 3 * fm.getHeight()); g.drawString(weekdayNames[Calendar.WEDNESDAY], insets.left + 3 * fieldWidth + (fieldWidth - fm.stringWidth(weekdayNames[Calendar.WEDNESDAY])) / 2, insets.top + 3 * fm.getHeight()); g.drawString(weekdayNames[Calendar.THURSDAY], insets.left + 4 * fieldWidth + (fieldWidth - fm.stringWidth(weekdayNames[Calendar.THURSDAY])) / 2, insets.top + 3 * fm.getHeight()); g.drawString(weekdayNames[Calendar.FRIDAY], insets.left + 5 * fieldWidth + (fieldWidth - fm.stringWidth(weekdayNames[Calendar.FRIDAY])) / 2, insets.top + 3 * fm.getHeight()); g.drawString(weekdayNames[Calendar.SATURDAY], insets.left + 6 * fieldWidth + (fieldWidth - fm.stringWidth(weekdayNames[Calendar.SATURDAY])) / 2, insets.top + 3 * fm.getHeight()); int dom = cal.get(Calendar.DAY_OF_MONTH); cal.set(Calendar.DAY_OF_MONTH, 1); int col = 0; switch (cal.get(Calendar.DAY_OF_WEEK)) { case Calendar.MONDAY: col = 1; break; case Calendar.TUESDAY: col = 2; break; case Calendar.WEDNESDAY: col = 3; break; case Calendar.THURSDAY: col = 4; break; case Calendar.FRIDAY: col = 5; break; case Calendar.SATURDAY: col = 6; } cal.set(Calendar.DAY_OF_MONTH, dom); int row = 5 * fm.getHeight(); for (int i = 1; i <= cal.getActualMaximum(Calendar.DAY_OF_MONTH); i++) { g.drawString("" + i, insets.left + fieldWidth * col + (fieldWidth - fm.stringWidth("" + i)) / 2, row); if (++col > 6) { col = 0; row += fm.getHeight(); } } }