/**
  * Utility method used to return the day of the week as a string representation.
  *
  * @param day day of the week as integer
  * @return day of the week as string
  */
 private static String getWeekDay(int day) {
   if (weekDays == null) {
     DateFormatSymbols dfs = new DateFormatSymbols(WebEngine.getActiveContext().getLocale());
     weekDays = dfs.getWeekdays();
   }
   return weekDays[day];
 }
    public String toString(Context context, boolean showNever) {
      StringBuilder ret = new StringBuilder();

      // no days
      if (mDays == 0) {
        return showNever ? context.getText(R.string.never).toString() : "";
      }

      // every day
      if (mDays == 0x7f) {
        return context.getText(R.string.every_day).toString();
      }

      // count selected days
      int dayCount = 0, days = mDays;
      while (days > 0) {
        if ((days & 1) == 1) dayCount++;
        days >>= 1;
      }

      // short or long form?
      DateFormatSymbols dfs = new DateFormatSymbols();
      String[] dayList = (dayCount > 1) ? dfs.getShortWeekdays() : dfs.getWeekdays();

      // selected days
      for (int i = 0; i < 7; i++) {
        if ((mDays & (1 << i)) != 0) {
          ret.append(dayList[DAY_MAP[i]]);
          dayCount -= 1;
          if (dayCount > 0) ret.append(context.getText(R.string.day_concat));
        }
      }
      return ret.toString();
    }
Example #3
0
  /**
   * Converts a string to a month code.
   *
   * <p>This method will return one of the constants JANUARY, FEBRUARY, ..., DECEMBER that
   * corresponds to the string. If the string is not recognised, this method returns -1.
   *
   * @param s the string to parse.
   * @return <code>-1</code> if the string is not parseable, the month of the year otherwise.
   */
  public static int stringToMonthCode(String s) {

    final String[] shortMonthNames = DATE_FORMAT_SYMBOLS.getShortMonths();
    final String[] monthNames = DATE_FORMAT_SYMBOLS.getMonths();

    int result = -1;
    s = s.trim();

    // first try parsing the string as an integer (1-12)...
    try {
      result = Integer.parseInt(s);
    } catch (NumberFormatException e) {
      // suppress
    }

    // now search through the month names...
    if ((result < 1) || (result > 12)) {
      for (int i = 0; i < monthNames.length; i++) {
        if (s.equals(shortMonthNames[i])) {
          result = i + 1;
          break;
        }
        if (s.equals(monthNames[i])) {
          result = i + 1;
          break;
        }
      }
    }

    return result;
  }
  @Test
  public void testItAbbreviatesDayNames() {
    // simulate Feb month
    when(calendar.get(Calendar.DAY_OF_WEEK)).thenReturn(1);
    when(calendar.get(Calendar.MONTH)).thenReturn(1);
    when(calendar.getActualMaximum(Calendar.DAY_OF_MONTH)).thenReturn(28);

    underTest.setGrowProgress(
        1000); // set grow progress so that it simulates the calendar being open
    underTest.setLocale(Locale.FRANCE);
    reset(canvas); // reset because invalidate is called
    underTest.setUseWeekDayAbbreviation(true);
    reset(canvas); // reset because invalidate is called
    underTest.drawMonth(canvas, calendar, 0);

    DateFormatSymbols dateFormatSymbols = new DateFormatSymbols(Locale.FRANCE);
    String[] dayNames = dateFormatSymbols.getShortWeekdays();

    InOrder inOrder = inOrder(canvas);
    inOrder.verify(canvas).drawText(eq(dayNames[2]), anyInt(), anyInt(), eq(paint));
    inOrder.verify(canvas).drawText(eq(dayNames[3]), anyInt(), anyInt(), eq(paint));
    inOrder.verify(canvas).drawText(eq(dayNames[4]), anyInt(), anyInt(), eq(paint));
    inOrder.verify(canvas).drawText(eq(dayNames[5]), anyInt(), anyInt(), eq(paint));
    inOrder.verify(canvas).drawText(eq(dayNames[6]), anyInt(), anyInt(), eq(paint));
    inOrder.verify(canvas).drawText(eq(dayNames[7]), anyInt(), anyInt(), eq(paint));
    inOrder.verify(canvas).drawText(eq(dayNames[1]), anyInt(), anyInt(), eq(paint));
  }
Example #5
0
  /**
   * Returns an array of month names.
   *
   * @param shortened a flag indicating that shortened month names should be returned.
   * @return an array of month names.
   */
  public static String[] getMonths(final boolean shortened) {

    if (shortened) {
      return DATE_FORMAT_SYMBOLS.getShortMonths();
    } else {
      return DATE_FORMAT_SYMBOLS.getMonths();
    }
  }
Example #6
0
 private List<LocalizedLabel> getNameOfMonths(AuraLocale locale) throws QuickFixException {
   DateFormatSymbols monthSymbols = DateFormatSymbols.getInstance(locale.getLanguageLocale());
   String[] months = monthSymbols.getMonths();
   String[] shortMonths = monthSymbols.getShortMonths();
   ArrayList<LocalizedLabel> monthList = new ArrayList<>(months.length);
   for (int i = 0; i < months.length; i++) {
     monthList.add(new LocalizedLabel(months[i], shortMonths[i]));
   }
   return monthList;
 }
  /**
   * This method will render the graph according to the choosen year
   *
   * @param year
   * @param comName
   * @throws SystemException
   * @return view * @throws Exception * @throws BusinessException * @throws BusinessException
   * @throws SystemException
   */
  @RequestMapping(value = "yearly", method = RequestMethod.POST)
  public ModelAndView selectyear(
      @ModelAttribute("year") int year, @ModelAttribute("company_name") String comName)
      throws BusinessException, SystemException {
    logger.info("selectyear():called.");
    List<History> newlist = new ArrayList<History>();
    History h = new History();

    list = hs.selectyear(comName, year);
    if (list.isEmpty()) {
      logger.error("failed while generating graph");
      throw new BusinessException(
          "No matching record found in the database. Please refine your business criteria..");
    }
    for (int i = 0; i < list.size() - 1; i++) {

      if (list.get(i).getDate().getMonth() != (list.get(i + 1).getDate().getMonth())) {
        h = list.get(i);
        if (h != null) {
          newlist.add(h);
        }
        if (i == list.size() - 2) {
          newlist.add(list.get(i + 1));
        }
      }
    }
    logger.debug(list);

    ModelAndView mav = new ModelAndView();
    String str = "[['x','Stock Price'],[";
    for (int i = 0; i < newlist.size(); i++) {
      str = str + "'";
      int mon = newlist.get(i).getDate().getMonth();
      DateFormatSymbols symbols;
      symbols = new DateFormatSymbols();
      String month = symbols.getMonths()[mon - 1];
      str = str + month;
      str = str + "'";
      str = str + ",";
      str = str + newlist.get(i).getPrice();
      str = str + "]";
      if (i != newlist.size() - 1) {
        str = str + ",[";
      }
    }
    str = str + "]";
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("Name", comName);
    map.put("string", str);
    mav.addObject("map", map);
    mav.setViewName(displaygraph);
    return mav;
  }
Example #8
0
 private List<LocalizedLabel> getNameOfWeekdays(AuraLocale locale) throws QuickFixException {
   DateFormatSymbols weekdaySymbols = DateFormatSymbols.getInstance(locale.getLanguageLocale());
   String[] weekdays = weekdaySymbols.getWeekdays();
   String[] shortWeekdays = weekdaySymbols.getShortWeekdays();
   ArrayList<LocalizedLabel> weekdayList = new ArrayList<>(7);
   for (int i = 1; i < weekdays.length; i++) {
     weekdayList.add(
         new LocalizedLabel(
             weekdays[i], shortWeekdays[i].toUpperCase(locale.getLanguageLocale())));
   }
   return weekdayList;
 }
  /**
   * Returns a lookup from recurrence rule days of the week, to the proper days of the week in the
   * specified locale
   */
  public static Map<String, String> buildLocalRecurrenceDaysOfTheWeek(Locale locale) {
    // Get our days of the week, in the current locale
    DateFormatSymbols dates = new DateFormatSymbols(I18NUtil.getLocale());
    String[] weekdays = dates.getWeekdays();

    // And map them based on the outlook two letter codes
    Map<String, String> days = new HashMap<String, String>();
    for (Map.Entry<String, Integer> e : DAY_NAMES_TO_CALENDAR_DAYS.entrySet()) {
      days.put(e.getKey(), weekdays[e.getValue()]);
    }
    return days;
  }
Example #10
0
  /* look for the rate in te account file for the time in the login string */
  public RateEntry getRate(String login) {
    int logday = 0, rateday = 0;
    //    System.out.println("getRate: login='******'");
    String day, time, rate = null;
    StringTokenizer st = new StringTokenizer(login);
    // frits     pts/21       flash            Fri Mar 18 13:46 - 14:30 (6+00:44)
    //                                        ^              ^
    day = st.nextToken();
    time = st.nextToken();
    time = st.nextToken();
    time = st.nextToken().substring(0, 5);
    // System.out.println(login+" "+day+" "+time);
    // Get the international names of the days and which day is (1,2,3...
    // Then find day of each rate entry, (1,2,3,4
    // Now we can compare, independent of the language used for the days
    // Finally use the time to compare as well
    DateFormatSymbols dfs = new DateFormatSymbols();
    String[] days = dfs.getShortWeekdays();
    for (int j = 1; j < days.length; j++) {
      if (day.compareTo(days[j]) == 0) {
        logday = j;
        break;
      }
    }
    // logday -> the day given in the gorecords.xml file (the log)

    int n = rates.size();
    // the last rate applies if before the first entry
    // Init to last rate given in the account
    RateEntry tmpRE, saveRE = rates(n - 1);
    //    System.out.println("n="+n);
    for (int i = 0; i < n; i++) {
      tmpRE = rates(i);
      for (int j = 1; j < days.length; j++) {
        if (tmpRE.day.compareTo(days[j]) == 0) {
          rateday = j;
          break;
        }
      }
      //    System.out.println("j="+jday+" k="+kday+" "+tmpRE.time+" "+tmpRE.loginhr);
      // the last rate applies if before the first entry
      if (logday > rateday) {
        saveRE = tmpRE;
      }
      if ((logday == rateday) && (time.compareTo(tmpRE.time) >= 0)) {
        saveRE = tmpRE;
      }
    }
    return saveRE;
  }
  void test2() {
    Locale defaultLocale = Locale.getDefault();
    TimeZone reservedTimeZone = TimeZone.getDefault();
    Date d = new Date(2005 - 1900, Calendar.DECEMBER, 22);
    String formatted;

    TimeZone tz;
    SimpleDateFormat df;

    try {
      for (int i = 0; i < TIMEZONES.length; i++) {
        tz = TimeZone.getTimeZone(TIMEZONES[i]);
        TimeZone.setDefault(tz);
        df = new SimpleDateFormat(pattern, DateFormatSymbols.getInstance(OSAKA));
        Locale.setDefault(defaultLocale);
        System.out.println(formatted = df.format(d));
        if (!formatted.equals(DISPLAY_NAMES_OSAKA[i])) {
          throw new RuntimeException(
              "TimeZone "
                  + TIMEZONES[i]
                  + ": formatted zone names mismatch. "
                  + formatted
                  + " should match with "
                  + DISPLAY_NAMES_OSAKA[i]);
        }

        df.parse(DISPLAY_NAMES_OSAKA[i]);

        Locale.setDefault(KYOTO);
        df = new SimpleDateFormat(pattern, DateFormatSymbols.getInstance());
        System.out.println(formatted = df.format(d));
        if (!formatted.equals(DISPLAY_NAMES_KYOTO[i])) {
          throw new RuntimeException(
              "Timezone "
                  + TIMEZONES[i]
                  + ": formatted zone names mismatch. "
                  + formatted
                  + " should match with "
                  + DISPLAY_NAMES_KYOTO[i]);
        }
        df.parse(DISPLAY_NAMES_KYOTO[i]);
      }
    } catch (ParseException pe) {
      throw new RuntimeException("parse error occured" + pe);
    } finally {
      // restore the reserved locale and time zone
      Locale.setDefault(defaultLocale);
      TimeZone.setDefault(reservedTimeZone);
    }
  }
Example #12
0
  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).
    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 #13
0
 /**
  * Returns a new {@code SimpleDateFormat} with the same pattern and properties as this simple date
  * format.
  */
 @Override
 public Object clone() {
   SimpleDateFormat clone = (SimpleDateFormat) super.clone();
   clone.formatData = (DateFormatSymbols) formatData.clone();
   clone.defaultCenturyStart = new Date(defaultCenturyStart.getTime());
   return clone;
 }
Example #14
0
 /** @param evt */
 @SuppressWarnings("unchecked")
 private void sundayCheckActionPerformed(java.awt.event.ActionEvent evt) {
   if (this.sundayCheck.isSelected()) {
     this.numSelected++;
     if (this.firstSelection) {
       stretch();
     }
     // SWAP, 1 TEAM: 03
     //
     // QUALITY CHANGES
     //
     // Moved the duplicate code into a method for setting the Horizontal
     // and vertical tab groups
     // This overcame the duplicated code Bad code smell
     this.sundayJobList.setModel(this.models[0]);
     sundayTab.DayPanelSet(
         models,
         this,
         sundayJobList,
         sundayJobName,
         sundayLabel,
         sundayAddJob,
         sundayDeleteJob,
         sundayScrollPane);
     sundayTab.setUp(0);
     this.dayTabs.addTab(dfs.getWeekdays()[1], this.sundayTab);
   } else {
     this.numSelected--;
     stretch();
     this.dayTabs.remove(this.sundayTab);
   }
 }
Example #15
0
    /**
     * Construct a Strategy that parses a TimeZone
     *
     * @param locale The Locale
     */
    TimeZoneStrategy(final Locale locale) {
      final String[][] zones = DateFormatSymbols.getInstance(locale).getZoneStrings();
      for (String[] zone : zones) {
        if (zone[ID].startsWith("GMT")) {
          continue;
        }
        final TimeZone tz = TimeZone.getTimeZone(zone[ID]);
        if (!tzNames.containsKey(zone[LONG_STD])) {
          tzNames.put(zone[LONG_STD], tz);
        }
        if (!tzNames.containsKey(zone[SHORT_STD])) {
          tzNames.put(zone[SHORT_STD], tz);
        }
        if (tz.useDaylightTime()) {
          if (!tzNames.containsKey(zone[LONG_DST])) {
            tzNames.put(zone[LONG_DST], tz);
          }
          if (!tzNames.containsKey(zone[SHORT_DST])) {
            tzNames.put(zone[SHORT_DST], tz);
          }
        }
      }

      final StringBuilder sb = new StringBuilder();
      sb.append("(GMT[+\\-]\\d{0,1}\\d{2}|[+\\-]\\d{2}:?\\d{2}|");
      for (final String id : tzNames.keySet()) {
        escapeRegex(sb, id, false).append('|');
      }
      sb.setCharAt(sb.length() - 1, ')');
      validTimeZoneChars = sb.toString();
    }
Example #16
0
  /** @param evt */
  @SuppressWarnings("unchecked")
  private void saturdayCheckActionPerformed(java.awt.event.ActionEvent evt) {
    if (this.saturdayCheck.isSelected()) {
      this.numSelected++;
      if (this.firstSelection) {
        stretch();
      }
      this.saturdayJobList.setModel(this.models[6]);
      saturdayTab.DayPanelSet(
          models,
          this,
          saturdayJobList,
          saturdayJobName,
          saturdayLabel,
          saturdayAddJob,
          saturdayDeleteJob,
          saturdayScrollPane);
      saturdayTab.setUp(6);

      this.dayTabs.addTab(dfs.getWeekdays()[7], this.saturdayTab);
    } else {
      this.numSelected--;
      stretch();
      this.dayTabs.remove(this.saturdayTab);
    }
  }
Example #17
0
  /**
   * Used to edit days.
   *
   * @param days
   */
  @SuppressWarnings("unchecked")
  public Config(ArrayList<Day> days, Locale locale) {
    this.models = new DefaultListModel[7];
    for (int x = 0; x < 7; x++) {
      this.models[x] = new DefaultListModel<String>();
    }
    this.locale = locale;
    this.dfs = DateFormatSymbols.getInstance(Main.getLocale());
    initDyn();
    initComponents();

    // SWAP, 1 TEAM: 03
    //
    // QUALITY CHANGES
    //
    // Removed the if statement inside of the loop because it all did the
    // same stuff except for the do click
    // which i moved to a new method called performClickForDay()
    // This overcame the duplicated code Bad code smell
    for (Day day : days) {
      int dayIndex = day.getIndexOfDay();

      performClickForDay(dayIndex);
      ArrayList<String> jobs = day.getJobs();

      for (String job : jobs) {
        this.models[dayIndex].addElement(job);
      }
    }
  }
  private void updateDisplay() {
    if (this.mDayOfWeekView != null) {
      this.mCalendar.setFirstDayOfWeek(mWeekStart);
      this.mDayOfWeekView.setText(
          dateformartsymbols.getWeekdays()[this.mCalendar.get(Calendar.DAY_OF_WEEK)].toUpperCase(
              Locale.getDefault()));
    }

    this.mSelectedMonthTextView.setText(
        dateformartsymbols.getMonths()[this.mCalendar.get(Calendar.MONTH)].toUpperCase(
            Locale.getDefault()));
    this.mSelectedDayTextView.setText(DAY_FORMAT.format(this.mCalendar.getTime()));
    this.mYearView.setText(YEAR_FORMAT.format(this.mCalendar.getTime()));
    long timeInMillis = this.mCalendar.getTimeInMillis();
    String desc = DateUtils.formatDateTime(getActivity(), timeInMillis, 24);
    this.mMonthAndDayView.setContentDescription(desc);
  }
 @Nonnull
 public static DateFormatSymbols getInstance(final Locale aLocale) {
   // IFJDK5
   // return new DateFormatSymbols (aLocale);
   // ELSE
   return DateFormatSymbols.getInstance(aLocale);
   // ENDIF
 }
Example #20
0
  public static void main(String[] args) throws java.lang.Exception {
    Locale[] locales = Locale.getAvailableLocales();

    // sorting locales
    sortArray(Collator.getInstance(Locale.ENGLISH), locales);

    // comment first
    System.out.println("/*");
    int i = 0;
    for (Locale l : locales) {
      i++;
      if (l.getDisplayName().contains("(")) continue;
      if (blacklisted(i)) continue;
      System.out.print(" * " + i + " " + l.getDisplayName());
      System.out.println();
    }
    System.out.println(" */");

    // body
    i = 0;
    for (Locale l : locales) {
      i++;
      if (blacklisted(i)) continue;
      if (l.getDisplayName().contains("(")) continue;
      DateFormatSymbols symbols = new DateFormatSymbols(l);
      String[] dayNames = symbols.getShortWeekdays();

      // precompiler condition
      System.out.println("#if LANG == " + i);
      System.out.println("// " + l.getDisplayName());

      // day array body
      System.out.println("static const char* const DAYS[] = {");
      for (String s : dayNames) {
        if (s.length() == 0) continue;
        String norm = Normalizer.normalize(s, Normalizer.Form.NFD).replaceAll("[^\\p{ASCII}]", "");
        System.out.print("\"" + norm.toUpperCase() + "\",");
        System.out.println(" /* " + s + " */");
      }
      System.out.println("};");

      System.out.println("#endif ");
      System.out.println();
    }
  }
Example #21
0
  /**
   * Returns a string representing the supplied month.
   *
   * <p>The string returned is the long or short form of the month name taken from the default
   * locale.
   *
   * @param month the month.
   * @param shortened if <code>true</code> return the abbreviation of the month.
   * @return a string representing the supplied month.
   */
  public static String monthCodeToString(final int month, final boolean shortened) {

    // check arguments...
    if (!isValidMonthCode(month)) {
      throw new IllegalArgumentException(
          "SerialDate.monthCodeToString: month outside valid range.");
    }

    final String[] months;

    if (shortened) {
      months = DATE_FORMAT_SYMBOLS.getShortMonths();
    } else {
      months = DATE_FORMAT_SYMBOLS.getMonths();
    }

    return months[month - 1];
  }
 public JPanel getGuiPanel() {
   JPanel panel = new JPanel();
   JButton button = new JButton();
   button.addActionListener(new DoItListener());
   outputLabel = new JLabel("date appears here");
   DateFormatSymbols dateStuff = new DateFormatSymbols();
   month = new JComboBox(dateStuff.getMonths());
   day = new JTextField(8);
   year = new JTextField(8);
   JPanel inputPanel = new JPanel(new GridLayout(3, 2));
   inputPanel.add(new JLabel("Month"));
   inputPanel.add(month);
   inputPanel.add(new JLabel("Day"));
   inputPanel.add(day);
   inputPanel.add(new JLabel("Year"));
   inputPanel.add(button);
   inputPanel.add(outputLabel);
   return panel;
 }
Example #23
0
  /**
   * Converts the supplied string to a day of the week.
   *
   * @param s a string representing the day of the week.
   * @return <code>-1</code> if the string is not convertable, the day of the week otherwise.
   */
  public static int stringToWeekdayCode(String s) {

    final String[] shortWeekdayNames = DATE_FORMAT_SYMBOLS.getShortWeekdays();
    final String[] weekDayNames = DATE_FORMAT_SYMBOLS.getWeekdays();

    int result = -1;
    s = s.trim();
    for (int i = 0; i < weekDayNames.length; i++) {
      if (s.equals(shortWeekdayNames[i])) {
        result = i;
        break;
      }
      if (s.equals(weekDayNames[i])) {
        result = i;
        break;
      }
    }
    return result;
  }
Example #24
0
  /**
   * Returns the Calendar constant (e.g. <code>Calendar.SUNDAY</code>) for a given TVDb airday
   * string (Monday through Sunday and Daily). If no match is found -1 will be returned.
   *
   * @param day TVDb day string
   */
  private static int getDayOfWeek(String day) {
    // catch Daily
    if (day.equalsIgnoreCase("Daily")) {
      return 0;
    }

    // catch Monday through Sunday
    DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
    String[] weekdays = dfs.getWeekdays();

    for (int i = 1; i < weekdays.length; i++) {
      if (day.equalsIgnoreCase(weekdays[i])) {
        return i;
      }
    }

    // no match
    return -1;
  }
Example #25
0
 /**
  * Get a month's name for a month between 1 and 12. Any invalid month value (e.g. 0 or -1) will
  * return a value of "Unspecified".
  *
  * @param m the month number
  * @return the month name.
  */
 public static String getMonthName(int m, Locale locale) {
   if ((m > 0) && (m < 13)) {
     if (dfs == null || !langMonth.equals(locale)) {
       dfs = new DateFormatSymbols(locale);
       langMonth = locale;
     }
     return dfs.getMonths()[m - 1];
   } else {
     return "Unspecified";
   }
 }
Example #26
0
  public Config() {
    this.models = new DefaultListModel[7];
    for (int x = 0; x < 7; x++) {
      this.models[x] = new DefaultListModel<String>();
    }
    this.locale = Main.getLocale();
    this.dfs = DateFormatSymbols.getInstance(Main.getLocale());
    initDyn();

    initComponents();
  }
Example #27
0
  private void addLocalized(IWContext iwc) {
    Locale locale = iwc.getCurrentLocale();
    DateFormatSymbols symbols = new DateFormatSymbols(locale);
    IWBundle iwb = this.getBundle(iwc);
    IWResourceBundle iwrb = iwb.getResourceBundle(iwc);
    String[] monthStrings;

    if (this.showNullValue) {
      if (this.inShort) {
        this.dayString = iwrb.getLocalizedString(DAY_KEY_S, "D");
        this.monthString = iwrb.getLocalizedString(MONTH_KEY_S, "M");
        this.yearString = iwrb.getLocalizedString(YEAR_KEY_S, "Y");
      } else {
        this.dayString = iwrb.getLocalizedString(DAY_KEY, "Day");
        this.monthString = iwrb.getLocalizedString(MONTH_KEY, "Month");
        this.yearString = iwrb.getLocalizedString(YEAR_KEY, "Year");
      }
      this.theDay.setMenuElementDisplayString("00", this.dayString);
      this.theMonth.setMenuElementDisplayString("00", this.monthString);

      if (this.showYear) {
        this.theYear.setMenuElementDisplayString("YY", this.yearString);
      }
    }
    if (this.inShort) {
      monthStrings = symbols.getShortMonths();
    } else {
      monthStrings = symbols.getMonths();
    }

    for (int i = 1; i <= 12; i++) {
      String value = Integer.toString(i);

      if (i < 10) {
        value = "0" + value;
      }

      this.theMonth.setMenuElementDisplayString(value, monthStrings[i - 1]);
    }
  }
Example #28
0
    public AlarmItemAdapter(
        Context context,
        int[] expandedIds,
        int[] repeatCheckedIds,
        int[] selectedAlarms,
        Bundle previousDaysOfWeekMap,
        ListView list) {
      super(context, null, 0);
      mContext = context;
      mFactory = LayoutInflater.from(context);
      mList = list;

      DateFormatSymbols dfs = new DateFormatSymbols();
      mShortWeekDayStrings = dfs.getShortWeekdays();
      mLongWeekDayStrings = dfs.getWeekdays();

      Resources res = mContext.getResources();
      mColorLit = res.getColor(R.color.clock_white);
      mColorDim = res.getColor(R.color.clock_gray);
      mBackgroundColorSelected = res.getColor(R.color.alarm_selected_color);
      mBackgroundColor = res.getColor(R.color.alarm_whiteish);

      mRobotoBold = Typeface.create("sans-serif-condensed", Typeface.BOLD);
      mRobotoNormal = Typeface.create("sans-serif-condensed", Typeface.NORMAL);

      if (expandedIds != null) {
        buildHashSetFromArray(expandedIds, mExpanded);
      }
      if (repeatCheckedIds != null) {
        buildHashSetFromArray(repeatCheckedIds, mRepeatChecked);
      }
      if (previousDaysOfWeekMap != null) {
        mPreviousDaysOfWeekMap = previousDaysOfWeekMap;
      }
      if (selectedAlarms != null) {
        buildHashSetFromArray(selectedAlarms, mSelectedAlarms);
      }

      mHasVibrator = ((Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE)).hasVibrator();
    }
  /** Updates the week names, when the locale changed. */
  private void updateWeekNames() {
    DateFormatSymbols dateFormatSymbols =
        new DateFormatSymbols(calendarView.localeProperty().get());
    String[] weekDays = dateFormatSymbols.getShortWeekdays();

    // Start with 1 instead of 0, since the first element in the array is empty.
    for (int i = 1; i < weekDays.length; i++) {
      // Get the first character only.
      String shortWeekDay = weekDays[i].substring(0, 2);

      // Shift the index according to the first day of week.
      int j = i - calendarView.getCalendar().getFirstDayOfWeek();
      if (j < 0) {
        j += weekDays.length - 1;
      }

      Label label = (Label) getChildren().get(j + (calendarView.getShowWeeks() ? 1 : 0));

      label.setText(shortWeekDay);
    }
    title.set(getDateFormat("MMMM yyyy").format(calendarView.getCalendar().getTime()));
  }
Example #30
0
 /**
  * Compares the specified object with this simple date format and indicates if they are equal. In
  * order to be equal, {@code object} must be an instance of {@code SimpleDateFormat} and have the
  * same {@code DateFormat} properties, pattern, {@code DateFormatSymbols} and creation year.
  *
  * @param object the object to compare with this object.
  * @return {@code true} if the specified object is equal to this simple date format; {@code false}
  *     otherwise.
  * @see #hashCode
  */
 @Override
 public boolean equals(Object object) {
   if (this == object) {
     return true;
   }
   if (!(object instanceof SimpleDateFormat)) {
     return false;
   }
   SimpleDateFormat simple = (SimpleDateFormat) object;
   return super.equals(object)
       && pattern.equals(simple.pattern)
       && formatData.equals(simple.formatData);
 }