java.text.DateFormatSymbols Java Examples
The following examples show how to use
java.text.DateFormatSymbols.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestZoneTextPrinterParser.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
private void parseText(Set<String> zids, Locale locale, TextStyle style, boolean ci) { System.out.println("---------------------------------------"); DateTimeFormatter fmt = getFormatter(locale, style, ci); for (String[] names : new DateFormatSymbols(locale).getZoneStrings()) { if (!zids.contains(names[0])) { continue; } String zid = names[0]; String expected = ZoneName.toZid(zid, locale); parse(fmt, zid, expected, zid, locale, style, ci); int i = style == TextStyle.FULL ? 1 : 2; for (; i < names.length; i += 2) { parse(fmt, zid, expected, names[i], locale, style, ci); } } }
Example #2
Source File: Calendar.java From jdk-1.7-annotated with Apache License 2.0 | 6 votes |
private String[] getFieldStrings(int field, int style, DateFormatSymbols symbols) { String[] strings = null; switch (field) { case ERA: strings = symbols.getEras(); break; case MONTH: strings = (style == LONG) ? symbols.getMonths() : symbols.getShortMonths(); break; case DAY_OF_WEEK: strings = (style == LONG) ? symbols.getWeekdays() : symbols.getShortWeekdays(); break; case AM_PM: strings = symbols.getAmPmStrings(); break; } return strings; }
Example #3
Source File: MonthChooser.java From javamoney-examples with Apache License 2.0 | 6 votes |
/** * Constructs a new chooser with the specified month initially selected. * * @param month The month to initially select. */ public MonthChooser(int month) { String[] months = new DateFormatSymbols().getMonths(); for(String monthName : months) { // There is a month with no displayable text that is not to be added. if(monthName.length() != 0) { addItem(monthName); } } setSelectedMonth(month); setToolTipText(getProperty("MonthChooser.tip")); }
Example #4
Source File: CommonUtils.java From peppy-calendarview with MIT License | 6 votes |
public static String[] getWeekDaysAbbreviation(int firstDayOfWeek) { if (firstDayOfWeek < 1 || firstDayOfWeek > 7) { throw new IllegalArgumentException("Day must be from Java Calendar class"); } DateFormatSymbols dateFormatSymbols = new DateFormatSymbols(Locale.getDefault()); String[] shortWeekdays = dateFormatSymbols.getShortWeekdays(); String[] weekDaysFromSunday = new String[]{shortWeekdays[1], shortWeekdays[2], shortWeekdays[3], shortWeekdays[4], shortWeekdays[5], shortWeekdays[6], shortWeekdays[7]}; String[] weekDaysNames = new String[7]; for (int day = firstDayOfWeek - 1, i = 0; i < 7; i++, day++) { day = day >= 7 ? 0 : day; weekDaysNames[i] = weekDaysFromSunday[day].toUpperCase(); } return weekDaysNames; }
Example #5
Source File: TestZoneTextPrinterParser.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
private void parseText(Set<String> zids, Locale locale, TextStyle style, boolean ci) { System.out.println("---------------------------------------"); DateTimeFormatter fmt = getFormatter(locale, style, ci); for (String[] names : new DateFormatSymbols(locale).getZoneStrings()) { if (!zids.contains(names[0])) { continue; } String zid = names[0]; String expected = ZoneName.toZid(zid, locale); parse(fmt, zid, expected, zid, locale, style, ci); int i = style == TextStyle.FULL ? 1 : 2; for (; i < names.length; i += 2) { parse(fmt, zid, expected, names[i], locale, style, ci); } } }
Example #6
Source File: StringUtil.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public static Date str2dat( String arg0, String arg1, String val ) throws KettleValueException { SimpleDateFormat df = new SimpleDateFormat(); DateFormatSymbols dfs = new DateFormatSymbols(); if ( arg1 != null ) { dfs.setLocalPatternChars( arg1 ); } if ( arg0 != null ) { df.applyPattern( arg0 ); } try { return df.parse( val ); } catch ( Exception e ) { throw new KettleValueException( "TO_DATE Couldn't convert String to Date " + e.toString() ); } }
Example #7
Source File: MonthYearPickerDialogTest.java From monthyear-picker with Apache License 2.0 | 6 votes |
@Test public void builder() throws Exception { final int year = 2001; final int month = 6; final Context appContext = InstrumentationRegistry.getTargetContext(); final String title = String.format(Locale.getDefault(), "%s - %s", new DateFormatSymbols().getMonths()[month].toUpperCase(), year); InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() { @Override public void run() { MonthYearPickerDialog dialog = new MonthYearPickerDialog(appContext, year, month, null); dialog.create(); assertEquals(title, dialog.getTitle()); assertEquals(dialog.getButton(AlertDialog.BUTTON_POSITIVE).getVisibility(), View.VISIBLE); assertEquals(dialog.getButton(AlertDialog.BUTTON_NEGATIVE).getVisibility(), View.VISIBLE); } }); }
Example #8
Source File: StringUtil.java From hop with Apache License 2.0 | 6 votes |
public static Date str2dat( String arg0, String arg1, String val ) throws HopValueException { SimpleDateFormat df = new SimpleDateFormat(); DateFormatSymbols dfs = new DateFormatSymbols(); if ( arg1 != null ) { dfs.setLocalPatternChars( arg1 ); } if ( arg0 != null ) { df.applyPattern( arg0 ); } try { return df.parse( val ); } catch ( Exception e ) { throw new HopValueException( "TO_DATE Couldn't convert String to Date " + e.toString() ); } }
Example #9
Source File: LDIFInputData.java From hop with Apache License 2.0 | 6 votes |
public LDIFInputData() { super(); nrInputFields = -1; thisline = null; nextline = null; nf = NumberFormat.getInstance(); df = (DecimalFormat) nf; dfs = new DecimalFormatSymbols(); daf = new SimpleDateFormat(); dafs = new DateFormatSymbols(); nr_repeats = 0; filenr = 0; fr = null; zi = null; is = null; InputLDIF = null; recordLDIF = null; multiValueSeparator = ","; totalpreviousfields = 0; readrow = null; indexOfFilenameField = -1; }
Example #10
Source File: XMLInputSaxData.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public XMLInputSaxData() { super(); thisline = null; nextline = null; nf = NumberFormat.getInstance(); df = (DecimalFormat) nf; dfs = new DecimalFormatSymbols(); daf = new SimpleDateFormat(); dafs = new DateFormatSymbols(); nr_repeats = 0; previousRow = null; filenr = 0; fr = null; zi = null; is = null; }
Example #11
Source File: UIFenixCalendar.java From fenixedu-academic with GNU Lesser General Public License v3.0 | 6 votes |
private void encodeMonthRow(ResponseWriter writer, Calendar date, Locale locale) throws IOException { // writer.startElement("tr", this); // writer.startElement("td", this); writer.startElement("caption", this); writer.writeAttribute("style", "font-weight: 600; background: #bbb", null); writer.writeAttribute("class", "text-center", null); // writer.writeAttribute("colspan", 6, null); SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm", locale); DateFormatSymbols dfs = sdf.getDateFormatSymbols(); writer.write((dfs.getMonths())[date.get(Calendar.MONTH)]); writer.endElement("caption"); // writer.endElement("td"); // writer.endElement("tr"); }
Example #12
Source File: DatePickerSpinnerDelegate.java From DateTimePicker with Apache License 2.0 | 6 votes |
/** * Sets the current locale. * * @param locale The current locale. */ @Override protected void setCurrentLocale(Locale locale) { super.setCurrentLocale(locale); mTempDate = getCalendarForLocale(mTempDate, locale); mMinDate = getCalendarForLocale(mMinDate, locale); mMaxDate = getCalendarForLocale(mMaxDate, locale); mCurrentDate = getCalendarForLocale(mCurrentDate, locale); mNumberOfMonths = mTempDate.getActualMaximum(Calendar.MONTH) + 1; mShortMonths = new DateFormatSymbols().getShortMonths(); if (usingNumericMonths()) { // We're in a locale where a date should either be all-numeric, or all-text. // All-text would require custom NumberPicker formatters for day and year. mShortMonths = new String[mNumberOfMonths]; for (int i = 0; i < mNumberOfMonths; ++i) { mShortMonths[i] = String.format("%d", i + 1); } } }
Example #13
Source File: DateChooserPanel.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
/** * Returns a panel of buttons, each button representing a day in the month. This is a sub-component of the DatePanel. * * @return the panel. */ private JPanel getCalendarPanel() { final JPanel p = new JPanel( new GridLayout( 7, 7 ) ); final DateFormatSymbols dateFormatSymbols = new DateFormatSymbols(); final String[] weekDays = dateFormatSymbols.getShortWeekdays(); for ( int i = 0; i < this.WEEK_DAYS.length; i++ ) { p.add( new JLabel( weekDays[ this.WEEK_DAYS[ i ] ], SwingConstants.CENTER ) ); } this.buttons = new JButton[ 42 ]; for ( int i = 0; i < 42; i++ ) { final JButton b = new JButton( "" ); b.setMargin( new Insets( 1, 1, 1, 1 ) ); b.setName( Integer.toString( i ) ); b.setFont( this.dateFont ); b.setFocusPainted( false ); b.putClientProperty( "JButton.buttonType", "square" ); //$NON-NLS-1$ $NON-NLS-2$ this.buttons[ i ] = b; p.add( b ); } return p; }
Example #14
Source File: SectionDecorator.java From sakai with Educational Community License v2.0 | 6 votes |
private List<String> getAbbreviatedDayList() { List<String> list = new ArrayList<String>(); ResourceLoader rl = new ResourceLoader(); DateFormatSymbols dfs = DateFormatSymbols.getInstance(rl.getLocale()); String[] daysOfWeek = dfs.getShortWeekdays(); if(meeting.isMonday()) list.add(daysOfWeek[Calendar.MONDAY]); if(meeting.isTuesday()) list.add(daysOfWeek[Calendar.TUESDAY]); if(meeting.isWednesday()) list.add(daysOfWeek[Calendar.WEDNESDAY]); if(meeting.isThursday()) list.add(daysOfWeek[Calendar.THURSDAY]); if(meeting.isFriday()) list.add(daysOfWeek[Calendar.FRIDAY]); if(meeting.isSaturday()) list.add(daysOfWeek[Calendar.SATURDAY]); if(meeting.isSunday()) list.add(daysOfWeek[Calendar.SUNDAY]); return list; }
Example #15
Source File: QuietHoursActivity.java From GravityBox with Apache License 2.0 | 6 votes |
private void setupWeekDaysPref() { mPrefWeekDays = (MultiSelectListPreference) findPreference(PREF_KEY_QH_WEEKDAYS); String[] days = new DateFormatSymbols(Locale.getDefault()).getWeekdays(); CharSequence[] entries = new CharSequence[7]; CharSequence[] entryValues = new CharSequence[7]; for (int i = 1; i <= 7; i++) { entries[i - 1] = days[i]; entryValues[i - 1] = String.valueOf(i); } mPrefWeekDays.setEntries(entries); mPrefWeekDays.setEntryValues(entryValues); if (mPrefs.getStringSet(PREF_KEY_QH_WEEKDAYS, null) == null) { Set<String> value = new HashSet<String>(Arrays.asList("2", "3", "4", "5", "6")); mPrefs.edit().putStringSet(PREF_KEY_QH_WEEKDAYS, value).commit(); mPrefWeekDays.setValues(value); } }
Example #16
Source File: Value.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public Value dat2str( String arg0, String arg1 ) throws KettleValueException { if ( isNull() ) { setType( VALUE_TYPE_STRING ); } else { if ( getType() == VALUE_TYPE_DATE ) { SimpleDateFormat df = new SimpleDateFormat(); DateFormatSymbols dfs = new DateFormatSymbols(); if ( arg1 != null ) { dfs.setLocalPatternChars( arg1 ); } if ( arg0 != null ) { df.applyPattern( arg0 ); } try { setValue( df.format( getDate() ) ); } catch ( Exception e ) { setType( VALUE_TYPE_STRING ); setNull(); throw new KettleValueException( "TO_CHAR Couldn't convert Date to String " + e.toString() ); } } else { throw new KettleValueException( "Function DAT2STR only works on a date" ); } } return this; }
Example #17
Source File: DataFormatter.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Update formats when locale has been changed * * @param observable usually this is our own Observable instance * @param localeObj only reacts on Locale objects */ public void update(Observable observable, Object localeObj) { if (!(localeObj instanceof Locale)) return; Locale newLocale = (Locale)localeObj; if (!localeIsAdapting || newLocale.equals(locale)) return; locale = newLocale; dateSymbols = DateFormatSymbols.getInstance(locale); decimalSymbols = DecimalFormatSymbols.getInstance(locale); generalNumberFormat = new ExcelGeneralNumberFormat(locale); // taken from Date.toString() defaultDateformat = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", dateSymbols); defaultDateformat.setTimeZone(LocaleUtil.getUserTimeZone()); // init built-in formats formats.clear(); Format zipFormat = ZipPlusFourFormat.instance; addFormat("00000\\-0000", zipFormat); addFormat("00000-0000", zipFormat); Format phoneFormat = PhoneFormat.instance; // allow for format string variations addFormat("[<=9999999]###\\-####;\\(###\\)\\ ###\\-####", phoneFormat); addFormat("[<=9999999]###-####;(###) ###-####", phoneFormat); addFormat("###\\-####;\\(###\\)\\ ###\\-####", phoneFormat); addFormat("###-####;(###) ###-####", phoneFormat); Format ssnFormat = SSNFormat.instance; addFormat("000\\-00\\-0000", ssnFormat); addFormat("000-00-0000", ssnFormat); }
Example #18
Source File: DateFormatTest.java From j2objc with Apache License 2.0 | 5 votes |
/** * @tests java.text.DateFormat#getInstance() */ public void test_getInstance() { SimpleDateFormat f2 = (SimpleDateFormat) DateFormat.getInstance(); assertTrue("Wrong class", f2.getClass() == SimpleDateFormat.class); assertTrue("Wrong default", f2.equals(DateFormat.getDateTimeInstance( DateFormat.SHORT, DateFormat.SHORT, Locale.getDefault()))); assertTrue("Wrong symbols", f2.getDateFormatSymbols().equals( new DateFormatSymbols())); assertTrue("Doesn't work", f2.format(new Date()).getClass() == String.class); }
Example #19
Source File: LocaleTest.java From j2objc with Apache License 2.0 | 5 votes |
private static void assertObsolete(String newCode, String oldCode, String displayName) { // Either code should get you the same locale. Locale newLocale = new Locale(newCode); Locale oldLocale = new Locale(oldCode); assertEquals(newLocale, oldLocale); // No matter what code you used to create the locale, you should get the old code back. assertEquals(oldCode, newLocale.getLanguage()); assertEquals(oldCode, oldLocale.getLanguage()); // Check we get the right display name. assertEquals(displayName, newLocale.getDisplayLanguage(newLocale)); assertEquals(displayName, oldLocale.getDisplayLanguage(newLocale)); assertEquals(displayName, newLocale.getDisplayLanguage(oldLocale)); assertEquals(displayName, oldLocale.getDisplayLanguage(oldLocale)); // Check that none of the 'getAvailableLocales' methods are accidentally returning two // equal locales (because to ICU they're different, but we mangle one into the other). // TODO(kstanger): enable when BreakIterator is added. //assertOnce(newLocale, BreakIterator.getAvailableLocales()); assertOnce(newLocale, Calendar.getAvailableLocales()); assertOnce(newLocale, Collator.getAvailableLocales()); assertOnce(newLocale, DateFormat.getAvailableLocales()); assertOnce(newLocale, DateFormatSymbols.getAvailableLocales()); assertOnce(newLocale, NumberFormat.getAvailableLocales()); assertOnce(newLocale, Locale.getAvailableLocales()); }
Example #20
Source File: Lang_9_FastDateParser_s.java From coming with MIT License | 5 votes |
/** * Get the short and long values displayed for a field * @param field The field of interest * @return A sorted array of the field key / value pairs */ KeyValue[] getDisplayNames(int field) { Integer fieldInt = Integer.valueOf(field); KeyValue[] fieldKeyValues= nameValues.get(fieldInt); if(fieldKeyValues==null) { DateFormatSymbols symbols= DateFormatSymbols.getInstance(locale); switch(field) { case Calendar.ERA: // DateFormatSymbols#getEras() only returns AD/BC or translations // It does not work for the Thai Buddhist or Japanese Imperial calendars. // see: https://issues.apache.org/jira/browse/TRINIDAD-2126 Calendar c = Calendar.getInstance(locale); // N.B. Some calendars have different short and long symbols, e.g. ja_JP_JP String[] shortEras = toArray(c.getDisplayNames(Calendar.ERA, Calendar.SHORT, locale)); String[] longEras = toArray(c.getDisplayNames(Calendar.ERA, Calendar.LONG, locale)); fieldKeyValues= createKeyValues(longEras, shortEras); break; case Calendar.DAY_OF_WEEK: fieldKeyValues= createKeyValues(symbols.getWeekdays(), symbols.getShortWeekdays()); break; case Calendar.AM_PM: fieldKeyValues= createKeyValues(symbols.getAmPmStrings(), null); break; case Calendar.MONTH: fieldKeyValues= createKeyValues(symbols.getMonths(), symbols.getShortMonths()); break; default: throw new IllegalArgumentException("Invalid field value "+field); } KeyValue[] prior = nameValues.putIfAbsent(fieldInt, fieldKeyValues); if(prior!=null) { fieldKeyValues= prior; } } return fieldKeyValues; }
Example #21
Source File: JGenProg2017_0013_s.java From coming with MIT License | 5 votes |
/** * Get the short and long values displayed for a field * @param field The field of interest * @return A sorted array of the field key / value pairs */ KeyValue[] getDisplayNames(int field) { Integer fieldInt = Integer.valueOf(field); KeyValue[] fieldKeyValues= nameValues.get(fieldInt); if(fieldKeyValues==null) { DateFormatSymbols symbols= DateFormatSymbols.getInstance(locale); switch(field) { case Calendar.ERA: // DateFormatSymbols#getEras() only returns AD/BC or translations // It does not work for the Thai Buddhist or Japanese Imperial calendars. // see: https://issues.apache.org/jira/browse/TRINIDAD-2126 Calendar c = Calendar.getInstance(locale); // N.B. Some calendars have different short and long symbols, e.g. ja_JP_JP String[] shortEras = toArray(c.getDisplayNames(Calendar.ERA, Calendar.SHORT, locale)); String[] longEras = toArray(c.getDisplayNames(Calendar.ERA, Calendar.LONG, locale)); fieldKeyValues= createKeyValues(longEras, shortEras); break; case Calendar.DAY_OF_WEEK: fieldKeyValues= createKeyValues(symbols.getWeekdays(), symbols.getShortWeekdays()); break; case Calendar.AM_PM: fieldKeyValues= createKeyValues(symbols.getAmPmStrings(), null); break; case Calendar.MONTH: fieldKeyValues= createKeyValues(symbols.getMonths(), symbols.getShortMonths()); break; default: throw new IllegalArgumentException("Invalid field value "+field); } KeyValue[] prior = nameValues.putIfAbsent(fieldInt, fieldKeyValues); if(prior!=null) { fieldKeyValues= prior; } } return fieldKeyValues; }
Example #22
Source File: AlarmConfigFragment.java From prayer-times-android with Apache License 2.0 | 5 votes |
private void initWeekdays() { String[] weekdays = new DateFormatSymbols().getWeekdays(); //rotate arrays to match first weekday int firstWeekday = Calendar.getInstance().getFirstDayOfWeek(); if (firstWeekday != Calendar.SUNDAY) {//java default is sunday, nothing to do TextView[] wds = mWeekdays.clone(); TextView[] wdTs = mWeekdaysText.clone(); for (int i = 0; i < 7; i++) { mWeekdays[i] = wds[(8 - firstWeekday + i) % 7]; mWeekdaysText[i] = wdTs[(8 - firstWeekday + i) % 7]; } } for (int i = 0; i < 7; i++) { mWeekdays[i].setText(weekdays[i + 1].replace("ال", "").substring(0, 1)); mWeekdaysText[i].setText(weekdays[i + 1]); final int weekday = i + 1; setWeekday(i + 1, isWeekday(weekday)); mWeekdays[i].setOnClickListener(v -> { getActivity().getWindow().getDecorView().performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); setWeekday(weekday, !isWeekday(weekday)); }); } }
Example #23
Source File: SimpleDateFormatTest.java From j2objc with Apache License 2.0 | 5 votes |
public void test_hashCode() { SimpleDateFormat format = (SimpleDateFormat) DateFormat.getInstance(); SimpleDateFormat clone = (SimpleDateFormat) format.clone(); assertTrue("clone has not equal hash code", clone.hashCode() == format.hashCode()); format.format(new Date()); assertTrue("clone has not equal hash code after format", clone.hashCode() == format.hashCode()); DateFormatSymbols symbols = new DateFormatSymbols(Locale.ENGLISH); symbols.setEras(new String[] { "Before", "After" }); SimpleDateFormat format2 = new SimpleDateFormat("y'y'yy", symbols); assertFalse("objects has equal hash code", format2.hashCode() == format.hashCode()); }
Example #24
Source File: Value.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public Value str2dat( String arg0, String arg1 ) throws KettleValueException { if ( isNull() ) { setType( VALUE_TYPE_DATE ); } else { // System.out.println("Convert string ["+string+"] to date using pattern '"+arg0+"'"); SimpleDateFormat df = new SimpleDateFormat(); DateFormatSymbols dfs = new DateFormatSymbols(); if ( arg1 != null ) { dfs.setLocalPatternChars( arg1 ); } if ( arg0 != null ) { df.applyPattern( arg0 ); } try { value.setDate( df.parse( getString() ) ); setType( VALUE_TYPE_DATE ); setLength( -1, -1 ); } catch ( Exception e ) { setType( VALUE_TYPE_DATE ); setNull(); throw new KettleValueException( "TO_DATE Couldn't convert String to Date" + e.toString() ); } } return this; }
Example #25
Source File: CalendarPanel.java From LGoodDatePicker with MIT License | 5 votes |
/** * setSizeOfMonthYearPanel, This sets the size of the panel at the top of the calendar that * holds the month and the year label. The size is calculated from the largest month name (in * pixels), that exists in locale and language that is being used by the date picker. */ private void setSizeOfMonthYearPanel() { // Skip this function if the settings have not been applied. if (settings == null) { return; } // Get the font metrics object. Font font = labelMonth.getFont(); Canvas canvas = new Canvas(); FontMetrics metrics = canvas.getFontMetrics(font); // Calculate the preferred height for the month and year panel. int heightNavigationButtons = buttonPreviousYear.getPreferredSize().height; int preferredHeightMonthLabel = labelMonth.getPreferredSize().height; int preferredHeightYearLabel = labelYear.getPreferredSize().height; int monthFontHeight = metrics.getHeight(); int monthFontHeightWithPadding = monthFontHeight + 2; int panelHeight = Math.max(monthFontHeightWithPadding, Math.max(preferredHeightMonthLabel, Math.max(preferredHeightYearLabel, heightNavigationButtons))); // Get the length of the longest translated month string (in pixels). DateFormatSymbols symbols = DateFormatSymbols.getInstance(settings.getLocale()); String[] allLocalMonths = symbols.getMonths(); int longestMonthPixels = 0; for (String month : allLocalMonths) { int monthPixels = metrics.stringWidth(month); longestMonthPixels = (monthPixels > longestMonthPixels) ? monthPixels : longestMonthPixels; } int yearPixels = metrics.stringWidth("_2000"); // Calculate the size of a box to hold the text with some padding. Dimension size = new Dimension(longestMonthPixels + yearPixels + 12, panelHeight); // Set the monthAndYearPanel to the appropriate constant size. monthAndYearOuterPanel.setMinimumSize(size); monthAndYearOuterPanel.setPreferredSize(size); // monthAndYearOuterPanel.setMaximumSize(size); // Redraw the panel. this.doLayout(); this.validate(); }
Example #26
Source File: Calendar.java From JDKSourceCode1.8 with MIT License | 5 votes |
private Map<String,Integer> getDisplayNamesImpl(int field, int style, Locale locale) { DateFormatSymbols symbols = DateFormatSymbols.getInstance(locale); String[] strings = getFieldStrings(field, style, symbols); if (strings != null) { Map<String,Integer> names = new HashMap<>(); for (int i = 0; i < strings.length; i++) { if (strings[i].length() == 0) { continue; } names.put(strings[i], i); } return names; } return null; }
Example #27
Source File: DayChooser.java From javamoney-examples with Apache License 2.0 | 5 votes |
private void buildPanel() { String[] days = new DateFormatSymbols().getShortWeekdays(); int start = getCalendar().getFirstDayOfWeek(); // Build panel. setFill(GridBagConstraints.BOTH); addSpacer(0, 0, 1, 1, 1, 16); // Weekdays. for(int len = 0, col = 1; len < MAX_COLUMNS; ++len) { add(createWeekdayLabel(days[start++]), col++, 0, 1, 1, 14, 0); if(start > MAX_COLUMNS) { start = SUNDAY; // Start the week over. } } addSpacer(8, 0, 1, 1, 1, 0); // Month days. for(int len = 0, row = 1; row <= MAX_ROWS; ++row) { for(int col = 1; col <= MAX_COLUMNS; ++col, ++len) { add(getMonthDays()[len], col, row, 1, 1, 0, 14); } } }
Example #28
Source File: Bug4621320.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public static void main(String args[]) { DateFormatSymbols dfs = new DateFormatSymbols(new Locale("uk","UA")); if (!dfs.getMonths()[2].equals("\u0431\u0435\u0440\u0435\u0437\u043d\u044f")) { throw new RuntimeException(); } }
Example #29
Source File: CalendarView.java From consulo with Apache License 2.0 | 5 votes |
private void fillMonths() { DateFormatSymbols dateFormatSymbols = new DateFormatSymbols(Locale.getDefault()); for (int i = Calendar.JANUARY; i <= Calendar.DECEMBER; i++) myMonths.addItem(dateFormatSymbols.getMonths()[i]); myMonths.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { refresh(); } }); }
Example #30
Source File: Lang_10_FastDateParser_t.java From coming with MIT License | 5 votes |
/** * Get the short and long values displayed for a field * @param field The field of interest * @return A sorted array of the field key / value pairs */ KeyValue[] getDisplayNames(int field) { Integer fieldInt = Integer.valueOf(field); KeyValue[] fieldKeyValues= nameValues.get(fieldInt); if(fieldKeyValues==null) { DateFormatSymbols symbols= DateFormatSymbols.getInstance(locale); switch(field) { case Calendar.ERA: // DateFormatSymbols#getEras() only returns AD/BC or translations // It does not work for the Thai Buddhist or Japanese Imperial calendars. // see: https://issues.apache.org/jira/browse/TRINIDAD-2126 Calendar c = Calendar.getInstance(locale); // N.B. Some calendars have different short and long symbols, e.g. ja_JP_JP String[] shortEras = toArray(c.getDisplayNames(Calendar.ERA, Calendar.SHORT, locale)); String[] longEras = toArray(c.getDisplayNames(Calendar.ERA, Calendar.LONG, locale)); fieldKeyValues= createKeyValues(longEras, shortEras); break; case Calendar.DAY_OF_WEEK: fieldKeyValues= createKeyValues(symbols.getWeekdays(), symbols.getShortWeekdays()); break; case Calendar.AM_PM: fieldKeyValues= createKeyValues(symbols.getAmPmStrings(), null); break; case Calendar.MONTH: fieldKeyValues= createKeyValues(symbols.getMonths(), symbols.getShortMonths()); break; default: throw new IllegalArgumentException("Invalid field value "+field); } KeyValue[] prior = nameValues.putIfAbsent(fieldInt, fieldKeyValues); if(prior!=null) { fieldKeyValues= prior; } } return fieldKeyValues; }