Package java.text

Examples of java.text.DateFormatSymbols$DateFormatSymbolsGetter


        // Test whether the "local pattern characters" are what we
        // are expecting - Locale.GERMAN and Locale.GERMANY, Locale.FRENCH all
        // returned the standard "English" pattern characters on my machine
        // for JDK 1.4 (JDK 1.3 was OK). The Austria/German locale was OK though
        String expectedChars = "GuMtkHmsSEDFwWahKzZ";
        DateFormatSymbols localizedSymbols = new DateFormatSymbols(localizedLocale);
        String localChars    = localizedSymbols.getLocalPatternChars();

        // different JDK versions seem to have different numbers of pattern characters
        int lth = localChars.length() > expectedChars.length() ? expectedChars.length() :
                     localChars.length() < expectedChars.length() ? localChars.length() : expectedChars.length();
        validLocalDateSymbols = expectedChars.substring(0, lth).equals(localChars.substring(0, lth));
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<String, Object>();
    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 (request.getAttribute(LOCALIZATION_CONFIGURED_FLAG) == null)
        {
            JSONObject spec = new JSONObject();

            DateFormatSymbols symbols = new DateFormatSymbols(locale);

            spec.put("months", new JSONArray(symbols.getMonths()));

            StringBuilder days = new StringBuilder();

            String[] weekdays = symbols.getWeekdays();

            for (int i = Calendar.SUNDAY; i <= Calendar.SATURDAY; i++)
            {
                days.append(weekdays[i].substring(0, 1));
            }
View Full Code Here

     * Returns an int to represent the given month (ex : 1 for January)
     * Returns -1 if the given string doesn't match any month
     * Try to match with complete name and then with short names
     */
    private static int computeMonth(String ss, Locale loc) {
        DateFormatSymbols sym = new DateFormatSymbols(loc);
        String[] monthsArray = sym.getMonths();
        String[] shortMonthsArray = sym.getShortMonths();
        for (int i=0; i<monthsArray.length; i++) {
            if (StringUtil.equalsIgnoreCase(monthsArray[i], ss)) {
                return i+1;
            }
        }
View Full Code Here

   String[] shortMonths;

   public DateTimeDateFormat()
   {
      super();
      shortMonths = new DateFormatSymbols().getShortMonths();
   }
View Full Code Here

    // check that changing the short weekdays does work...
    SimpleDateFormat sdf = new SimpleDateFormat("E", Locale.UK);
    sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
    Date jan1_2005 = new Date(1104537600000L);
    harness.check(sdf.format(jan1_2005), "Sat");
    DateFormatSymbols s = sdf.getDateFormatSymbols();
    s.setShortWeekdays(new String[] {"-", "S", "M", "T", "W", "T", "F", "S"});
    // remember s is just a copy of the original
    sdf.setDateFormatSymbols(s);
    harness.check(sdf.format(jan1_2005), "S");
   
    // check null argument - it isn't mentioned in the spec that this
View Full Code Here

    // date formatter...
    SimpleDateFormat sdf = new SimpleDateFormat("E", Locale.UK);
    sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
    Date jan1_2005 = new Date(1104537600000L);
    harness.check(sdf.format(jan1_2005), "Sat");
    DateFormatSymbols s = sdf.getDateFormatSymbols();
    s.setShortWeekdays(new String[] {"-", "S", "M", "T", "W", "T", "F", "S"});
    harness.check(sdf.format(jan1_2005), "Sat");
  }
View Full Code Here

  
    // check null argument - it isn't mentioned in the spec that this
    // should throw a NullPointerException, but that is such common
    // behaviour elsewhere that I'm assuming this is the expected
    // result
    DateFormatSymbols dfs = new DateFormatSymbols(Locale.UK);
    try
    {
      dfs.setWeekdays(null);
      harness.check(false);
    }
    catch (NullPointerException e)
    {
      harness.check(true);
View Full Code Here

    f1 = new SimpleDateFormat("yyyy");
    harness.check(!f1.equals(f2));                 // check 2
    f2 = new SimpleDateFormat("yyyy");
    harness.check(f1.equals(f2));                  // check 3
   
    DateFormatSymbols dfs1 = new DateFormatSymbols(Locale.GERMAN);
    DateFormatSymbols dfs2 = new DateFormatSymbols(Locale.ENGLISH);
    f1 = new SimpleDateFormat("yyyy", dfs1);
    f2 = new SimpleDateFormat("yyyy", dfs2);
    harness.check(!f1.equals(f2));                 // check 4
    f2.setDateFormatSymbols(dfs1);
    harness.check(f1.equals(f2));                  // check 5
View Full Code Here

  {
    harness.checkPoint("SimpleDateFormat(String, DateFormatSymbols)");

    // bug 4099975 suggests that the DateFormatSymbols argument is
    // cloned - check for this behaviour
    DateFormatSymbols s = new DateFormatSymbols(Locale.FRANCE);
    SimpleDateFormat f = new SimpleDateFormat("yyyy", s);
    harness.check(f.getDateFormatSymbols() != s);
    harness.check(f.getDateFormatSymbols().equals(s));

    // check null 'pattern' argument
    try
    {
      /* SimpleDateFormat f = */ new SimpleDateFormat(
        null, new DateFormatSymbols()
      );  
      harness.check(false);
    }
    catch (NullPointerException e)
    {
      harness.check(true);  
    }

    // check null 'formatData' argument
    try
    {
      /* SimpleDateFormat f = */ new SimpleDateFormat(
        "yyyy", (DateFormatSymbols) null
      );  
      harness.check(false);
    }
    catch (NullPointerException e)
    {
      harness.check(true);  
    }
   
    // check invalid argument
    try
    {
      /* SimpleDateFormat f = */ new SimpleDateFormat(
        "ZYXWVUT", new DateFormatSymbols()
      );  
      harness.check(false);
    }
    catch (IllegalArgumentException e)
    {
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.