Package java.text

Examples of java.text.DateFormatSymbols$DateFormatSymbolsGetter


        SimpleDateFormat f2 = new SimpleDateFormat();
        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);
    }
View Full Code Here


        assertTrue("Wrong class", f2.getClass() == SimpleDateFormat.class);
        assertEquals("Wrong pattern", "yyyy", f2.toPattern());
        assertTrue("Wrong locale", f2.equals(new SimpleDateFormat("yyyy",
                Locale.getDefault())));
        assertTrue("Wrong symbols", f2.getDateFormatSymbols().equals(
                new DateFormatSymbols()));
        assertTrue("Doesn't work",
                f2.format(new Date()).getClass() == String.class);

        // Invalid constructor value.
        try {
View Full Code Here

     *        java.text.DateFormatSymbols)
     */
    public void test_ConstructorLjava_lang_StringLjava_text_DateFormatSymbols() {
        // Test for method java.text.SimpleDateFormat(java.lang.String,
        // java.text.DateFormatSymbols)
        DateFormatSymbols symbols = new DateFormatSymbols(Locale.ENGLISH);
        symbols.setEras(new String[] { "Before", "After" });
        SimpleDateFormat f2 = new SimpleDateFormat("y'y'yy", symbols);
        assertTrue("Wrong class", f2.getClass() == SimpleDateFormat.class);
        assertEquals("Wrong pattern", "y'y'yy", f2.toPattern());
        assertTrue("Wrong symbols", f2.getDateFormatSymbols().equals(symbols));
        assertTrue("Doesn't work",
View Full Code Here

        SimpleDateFormat f2 = new SimpleDateFormat("'yyyy' MM yy",
                Locale.GERMAN);
        assertTrue("Wrong class", f2.getClass() == SimpleDateFormat.class);
        assertEquals("Wrong pattern", "'yyyy' MM yy", f2.toPattern());
        assertTrue("Wrong symbols", f2.getDateFormatSymbols().equals(
                new DateFormatSymbols(Locale.GERMAN)));
        assertTrue("Doesn't work",
                f2.format(new Date()).getClass() == String.class);
    }
View Full Code Here

     */
    public void test_getDateFormatSymbols() {
        // Test for method java.text.DateFormatSymbols
        // java.text.SimpleDateFormat.getDateFormatSymbols()
        SimpleDateFormat df = (SimpleDateFormat) DateFormat.getInstance();
        DateFormatSymbols dfs = df.getDateFormatSymbols();
        assertTrue("Symbols identical", dfs != df.getDateFormatSymbols());
    }
View Full Code Here

     */
    public void test_setDateFormatSymbolsLjava_text_DateFormatSymbols() {
        // Test for method void
        // java.text.SimpleDateFormat.setDateFormatSymbols(java.text.DateFormatSymbols)
        SimpleDateFormat f1 = new SimpleDateFormat("a");
        DateFormatSymbols symbols = new DateFormatSymbols();
        symbols.setAmPmStrings(new String[] { "morning", "night" });
        f1.setDateFormatSymbols(symbols);
        DateFormatSymbols newSym = f1.getDateFormatSymbols();
        assertTrue("Set incorrectly", newSym.equals(symbols));
        assertTrue("Not a clone", f1.getDateFormatSymbols() != symbols);
        String result = f1.format(new GregorianCalendar(1999, Calendar.JUNE,
                12, 3, 0).getTime());
        assertEquals("Incorrect symbols used", "morning", result);
        symbols.setEras(new String[] { "before", "after" });
View Full Code Here

    if (response.wasRendered(key))
    {
      return;
    }

    DateFormatSymbols dfSymbols = DateFormatSymbols.getInstance(locale);
    if (dfSymbols == null)
    {
      dfSymbols = new DateFormatSymbols(locale);
    }

    Map<String, Object> i18nVariables = new LinkedHashMap<>();
    setWidgetProperty(i18nVariables, "MONTHS_SHORT", filterEmpty(dfSymbols.getShortMonths()));
    setWidgetProperty(i18nVariables, "MONTHS_LONG", filterEmpty(dfSymbols.getMonths()));
    setWidgetProperty(i18nVariables, "WEEKDAYS_MEDIUM",
      filterEmpty(dfSymbols.getShortWeekdays()));
    setWidgetProperty(i18nVariables, "WEEKDAYS_LONG", filterEmpty(dfSymbols.getWeekdays()));

    i18nVariables.put("START_WEEKDAY", getFirstDayOfWeek(locale));

    if (Locale.SIMPLIFIED_CHINESE.equals(locale) || Locale.TRADITIONAL_CHINESE.equals(locale))
    {
      setWidgetProperty(i18nVariables, "WEEKDAYS_1CHAR",
        filterEmpty(substring(dfSymbols.getShortWeekdays(), 2, 1)));
      i18nVariables.put("WEEKDAYS_SHORT",
        filterEmpty(substring(dfSymbols.getShortWeekdays(), 2, 1)));
    }
    else
    {
      setWidgetProperty(i18nVariables, "WEEKDAYS_1CHAR",
        filterEmpty(substring(dfSymbols.getShortWeekdays(), 0, 1)));
      setWidgetProperty(i18nVariables, "WEEKDAYS_SHORT",
        filterEmpty(substring(dfSymbols.getShortWeekdays(), 0, 2)));
    }

    StringBuilder i18n = new StringBuilder(key);
    i18n.append('=');
    appendMapping(i18nVariables, i18n);
View Full Code Here

        if (!usePattern) {
            formatter = (DateFormat)getFormat(locale);
        } else if (locale == null) {
            formatter = new SimpleDateFormat(pattern);
        } else {
            DateFormatSymbols symbols = new DateFormatSymbols(locale);
            formatter = new SimpleDateFormat(pattern, symbols);
        }
        formatter.setLenient(false);
        return formatter;
    }
View Full Code Here

   * @param widgetProperties
   *            the current widget properties
   */
  protected void localize(Map<String, Object> widgetProperties)
  {
    DateFormatSymbols dfSymbols = null;
    if (GETINSTANCEMETHOD != null)
    {
      // try to use JDK 6 DateFormatSymbols.getInstance(Locale)
      try
      {
        dfSymbols = (DateFormatSymbols)GETINSTANCEMETHOD.invoke(null,
            new Object[] { getLocale() });
      }
      catch (Exception e)
      {
        // ignore
      }
    }
    if (dfSymbols == null)
    {
      dfSymbols = new DateFormatSymbols(getLocale());
    }

    setWidgetProperty(widgetProperties, "MONTHS_SHORT", filterEmpty(dfSymbols.getShortMonths()));
    setWidgetProperty(widgetProperties, "MONTHS_LONG", filterEmpty(dfSymbols.getMonths()));
    setWidgetProperty(widgetProperties, "WEEKDAYS_MEDIUM", filterEmpty(dfSymbols
        .getShortWeekdays()));
    setWidgetProperty(widgetProperties, "WEEKDAYS_LONG", filterEmpty(dfSymbols.getWeekdays()));

    widgetProperties.put("START_WEEKDAY", new Integer(Calendar.getInstance(getLocale())
        .getFirstDayOfWeek() - 1));

    if (Locale.SIMPLIFIED_CHINESE.equals(getLocale()) ||
        Locale.TRADITIONAL_CHINESE.equals(getLocale()))
    {
      setWidgetProperty(widgetProperties, "WEEKDAYS_1CHAR", filterEmpty(substring(dfSymbols
          .getShortWeekdays(), 2, 1)));
      widgetProperties.put("WEEKDAYS_SHORT", filterEmpty(substring(dfSymbols
          .getShortWeekdays(), 2, 1)));
    }
    else
    {
      setWidgetProperty(widgetProperties, "WEEKDAYS_1CHAR", filterEmpty(substring(dfSymbols
          .getShortWeekdays(), 0, 1)));
      setWidgetProperty(widgetProperties, "WEEKDAYS_SHORT", filterEmpty(substring(dfSymbols
          .getShortWeekdays(), 0, 2)));
    }
  }
View Full Code Here

      try
      {
        ResourceBundle oraElementsData =
          ResourceBundle.getBundle(_ORA_LOCALE_ELEMENTS_BASE, locale);

        DateFormatSymbols syms = new DateFormatSymbols(locale);

        String[] res = oraElementsData.getStringArray("AmPmMarkers");
        if (res != null)
          syms.setAmPmStrings(res);
        res = oraElementsData.getStringArray("Eras");
        if (res != null)
          syms.setEras(res);
        res = oraElementsData.getStringArray("MonthNames");
        if (res != null)
          syms.setMonths(res);
        res = oraElementsData.getStringArray("MonthAbbreviations");
        if (res != null)
          syms.setShortMonths(res);
        res = oraElementsData.getStringArray("DayAbbreviations");
        if (res != null)
          syms.setShortWeekdays(res);
        res = oraElementsData.getStringArray("DayNames");
        if (res != null)
          syms.setWeekdays(res);
        sdf = new SimpleDateFormat(pattern, syms);
      }
      catch (MissingResourceException e)
      {
        // the Oracle resource bundle must be screwed up, just use the default
View Full Code Here

TOP

Related Classes of java.text.DateFormatSymbols$DateFormatSymbolsGetter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.