当前位置: 首页>>代码示例>>Java>>正文


Java DateFormatSymbols.getWeekdays方法代码示例

本文整理汇总了Java中java.text.DateFormatSymbols.getWeekdays方法的典型用法代码示例。如果您正苦于以下问题:Java DateFormatSymbols.getWeekdays方法的具体用法?Java DateFormatSymbols.getWeekdays怎么用?Java DateFormatSymbols.getWeekdays使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.text.DateFormatSymbols的用法示例。


在下文中一共展示了DateFormatSymbols.getWeekdays方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDisplayNameArray

import java.text.DateFormatSymbols; //导入方法依赖的package包/类
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();
    }
    return null;
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:15,代码来源:FastDateParser.java

示例2: getDisplayNameArray

import java.text.DateFormatSymbols; //导入方法依赖的package包/类
private String[] getDisplayNameArray(int field, int style, Locale locale) {
	if (field < 0 || field >= FIELD_COUNT) {
		throw new IllegalArgumentException("bad field " + field);
	}
	checkStyle(style);
	DateFormatSymbols dfs = DateFormatSymbols.getInstance(locale);
	switch (field) {
		case AM_PM:
			return dfs.getAmPmStrings();
		case DAY_OF_WEEK:
			return (style == LONG) ? dfs.getWeekdays() : dfs.getShortWeekdays();
		case ERA:
			return dfs.getEras();
		case MONTH:
			return (style == LONG) ? dfs.getMonths() : dfs.getShortMonths();
	}
	return null;
}
 
开发者ID:jtransc,项目名称:jtransc,代码行数:19,代码来源:Calendar.java

示例3: buildLocalRecurrenceDaysOfTheWeek

import java.text.DateFormatSymbols; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:19,代码来源:CalendarRecurrenceHelper.java

示例4: getFieldStrings

import java.text.DateFormatSymbols; //导入方法依赖的package包/类
private String[] getFieldStrings(int field, int style, DateFormatSymbols symbols) {
    int baseStyle = getBaseStyle(style); // ignore the standalone mask

    // DateFormatSymbols doesn't support any narrow names.
    if (baseStyle == NARROW_FORMAT) {
        return null;
    }

    String[] strings = null;
    switch (field) {
    case ERA:
        strings = symbols.getEras();
        break;

    case MONTH:
        strings = (baseStyle == LONG) ? symbols.getMonths() : symbols.getShortMonths();
        break;

    case DAY_OF_WEEK:
        strings = (baseStyle == LONG) ? symbols.getWeekdays() : symbols.getShortWeekdays();
        break;

    case AM_PM:
        strings = symbols.getAmPmStrings();
        break;
    }
    return strings;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:29,代码来源:Calendar.java

示例5: toString

import java.text.DateFormatSymbols; //导入方法依赖的package包/类
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();
}
 
开发者ID:nordfalk,项目名称:EsperantoRadio,代码行数:39,代码来源:Alarm.java

示例6: DateFormatSymbolsEx

import java.text.DateFormatSymbols; //导入方法依赖的package包/类
public DateFormatSymbolsEx(Locale locale) {
	DateFormatSymbols dateFormatSymbols = new DateFormatSymbols(locale);

	months = dateFormatSymbols.getMonths();
	shortMonths = dateFormatSymbols.getShortMonths();
	weekdays = dateFormatSymbols.getWeekdays();
	shortWeekdays = dateFormatSymbols.getShortWeekdays();
	eras = dateFormatSymbols.getEras();
	ampms = dateFormatSymbols.getAmPmStrings();
}
 
开发者ID:indic-ocr,项目名称:LibreOCR,代码行数:11,代码来源:DateFormatSymbolsEx.java

示例7: createWeekdaySection

import java.text.DateFormatSymbols; //导入方法依赖的package包/类
private Composite createWeekdaySection(final Composite parent) {
    final Composite weekdaySection = new Composite(parent, SWT.NONE);

    final RowLayout layout = new RowLayout(SWT.HORIZONTAL);
    layout.spacing = 10;
    layout.pack = false;
    weekdaySection.setLayout(layout);

    // Microsoft's UI is not clever enough to present the days using the
    // appropriate locales first day of the
    // week no neither do we. We always display it as Monday-Sunday and
    // always have monday-friday checked as
    // weekdays by default.

    final DateFormatSymbols dateSymbols = new DateFormatSymbols();
    final String[] weekdayNames = dateSymbols.getWeekdays();

    mondayButton = SWTUtil.createButton(weekdaySection, SWT.CHECK, weekdayNames[Calendar.MONDAY]);
    tuesdayButton = SWTUtil.createButton(weekdaySection, SWT.CHECK, weekdayNames[Calendar.TUESDAY]);
    wednesdayButton = SWTUtil.createButton(weekdaySection, SWT.CHECK, weekdayNames[Calendar.WEDNESDAY]);
    thursdayButton = SWTUtil.createButton(weekdaySection, SWT.CHECK, weekdayNames[Calendar.THURSDAY]);
    fridayButton = SWTUtil.createButton(weekdaySection, SWT.CHECK, weekdayNames[Calendar.FRIDAY]);
    saturdayButton = SWTUtil.createButton(weekdaySection, SWT.CHECK, weekdayNames[Calendar.SATURDAY]);
    sundayButton = SWTUtil.createButton(weekdaySection, SWT.CHECK, weekdayNames[Calendar.SUNDAY]);

    mondayButton.setSelection(true);
    tuesdayButton.setSelection(true);
    wednesdayButton.setSelection(true);
    thursdayButton.setSelection(true);
    fridayButton.setSelection(true);
    saturdayButton.setSelection(false);
    sundayButton.setSelection(false);

    // Force it so that at least one check box must be selected in the
    // schedule days.
    final SelectionAdapter forceOneSelectedAdapter = new SelectionAdapter() {
        @Override
        public void widgetSelected(final SelectionEvent e) {
            if (!mondayButton.getSelection()
                && !tuesdayButton.getSelection()
                && !wednesdayButton.getSelection()
                && !thursdayButton.getSelection()
                && !fridayButton.getSelection()
                && !saturdayButton.getSelection()
                && !sundayButton.getSelection()) {
                ((Button) e.getSource()).setSelection(true);
            }
        }
    };

    mondayButton.addSelectionListener(forceOneSelectedAdapter);
    tuesdayButton.addSelectionListener(forceOneSelectedAdapter);
    wednesdayButton.addSelectionListener(forceOneSelectedAdapter);
    thursdayButton.addSelectionListener(forceOneSelectedAdapter);
    fridayButton.addSelectionListener(forceOneSelectedAdapter);
    saturdayButton.addSelectionListener(forceOneSelectedAdapter);
    sundayButton.addSelectionListener(forceOneSelectedAdapter);

    return weekdaySection;
}
 
开发者ID:Microsoft,项目名称:team-explorer-everywhere,代码行数:61,代码来源:TriggerTabPage.java

示例8: getOpeningTimes

import java.text.DateFormatSymbols; //导入方法依赖的package包/类
/**
 * Gets opening times of a restaurant.
 *
 * @param position the position
 * @return the opening times
 */
public String getOpeningTimes(int position) {
    // create a string builder for the result
    StringBuilder result = new StringBuilder();
    // get the restaurant
    Restaurant restaurant = getItems().get(position);

    if (restaurant != null) {
        // get the time schedules of the restaurant
        List<TimeSchedule> openingTimes = restaurant.getTimeSchedules();
        // the current day
        TimeSchedule currentDay;
        // Do not change locale! Calendar with locale germany is needed to get static day of week numbers.
        Calendar calendar = Calendar.getInstance(Locale.GERMANY);
        // get the number of the day of week
        int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);
        // get the locale from the context
        Locale userLocale = getContext().getResources().getConfiguration().locale;
        // create a new date format
        DateFormat dateFormat = new SimpleDateFormat("HH:mm", userLocale);
        // create new date format symbols
        DateFormatSymbols dateFormatSymbols = new DateFormatSymbols(userLocale);
        // get an array of localized weekdays from the date format symbols
        String weekdays[] = dateFormatSymbols.getWeekdays();
        // indicates if the offer times of the weekday were found
        boolean offerTimeOnWeekdayFound = false;

        result.append(getContext().getResources().getString(R.string.text_offer_time));
        result.append(" ");

        for(int i = 0; i < openingTimes.size() && !offerTimeOnWeekdayFound; i++) {
            if(openingTimes.get(i) != null){
                currentDay = openingTimes.get(i);

                if(currentDay.getDayOfWeek() != null
                        && currentDay.getDayOfWeek().getDayNumber() == dayOfWeek
                        && currentDay.getOfferStartTime() != null
                        && currentDay.getOfferEndTime() != null) {
                    offerTimeOnWeekdayFound = true;
                    result.append(dateFormat.format(currentDay.getOfferStartTime()));
                    result.append(" - ");
                    result.append(dateFormat.format(currentDay.getOfferEndTime()));
                    result.append(" ");
                    result.append(getContext().getResources().getString(R.string.text_hour));
                }
            }
        }
        if (!offerTimeOnWeekdayFound) {
            result.append(weekdays[dayOfWeek]);
            result.append(" ");
            result.append(getContext().getResources().getString(R.string.text_no_offertime));
        }
    }
    return  result.toString();
}
 
开发者ID:andju,项目名称:findlunch,代码行数:61,代码来源:RestaurantContent.java

示例9: getDisplayName

import java.text.DateFormatSymbols; //导入方法依赖的package包/类
/**
 * Returns a localised textual representation of the current value
 * of the given field using the specified style.  If there is no
 * applicable textual representation (e.g. the field has a numeric
 * value), then <code>null</code> is returned.  If one does exist,
 * then the value is obtained from {@link #get(int)} and converted
 * appropriately.  For example, if the <code>MONTH</code> field is
 * requested, then <code>get(MONTH)</code> is called.  This is then
 * converted to a textual representation based on its value and
 * the style requested; if the <code>LONG</code> style is requested
 * and the returned value is <code>11</code> from a
 * {@link GregorianCalendar} implementation, then <code>"December"</code>
 * is returned.  By default, a textual representation is available
 * for all fields which have an applicable value obtainable from
 * {@link java.text.DateFormatSymbols}.
 *
 * @param field the calendar field whose textual representation should
 *              be obtained.
 * @param style the style to use; either {@link #LONG} or {@link #SHORT}.
 * @param locale the locale to use for translation.
 * @return the textual representation of the given field in the specified
 *         style, or <code>null</code> if none is applicable.
 * @throws IllegalArgumentException if <code>field</code> or <code>style</code>
 *                                  or invalid, or the calendar is non-lenient
 *                                  and has invalid values.
 * @throws NullPointerException if <code>locale</code> is <code>null</code>.
 * @since 1.6
 */
public String getDisplayName(int field, int style, Locale locale)
{
  if (field < 0 || field >= FIELD_COUNT)
    throw new IllegalArgumentException("The field value, " + field +
                                       ", is invalid.");
  if (style != SHORT && style != LONG)
    throw new IllegalArgumentException("The style must be either " +
                                       "short or long.");
  if (field == YEAR || field == WEEK_OF_YEAR ||
      field == WEEK_OF_MONTH || field == DAY_OF_MONTH ||
      field == DAY_OF_YEAR || field == DAY_OF_WEEK_IN_MONTH ||
      field == HOUR || field == HOUR_OF_DAY || field == MINUTE ||
      field == SECOND || field == MILLISECOND)
    return null;

  int value = get(field);
  DateFormatSymbols syms = DateFormatSymbols.getInstance(locale);
  if (field == ERA)
    return syms.getEras()[value];
  if (field == MONTH)
    if (style == LONG)
      return syms.getMonths()[value];
    else
      return syms.getShortMonths()[value];
  if (field == DAY_OF_WEEK)
    if (style == LONG)
      return syms.getWeekdays()[value];
    else
      return syms.getShortWeekdays()[value];
  if (field == AM_PM)
    return syms.getAmPmStrings()[value];
  if (field == ZONE_OFFSET)
    if (style == LONG)
      return syms.getZoneStrings()[value][1];
    else
      return syms.getZoneStrings()[value][2];
  if (field == DST_OFFSET)
    if (style == LONG)
      return syms.getZoneStrings()[value][3];
    else
      return syms.getZoneStrings()[value][4];

  throw new InternalError("Failed to resolve field " + field +
                          " with style " + style + " for locale " +
                          locale);
}
 
开发者ID:vilie,项目名称:javify,代码行数:75,代码来源:Calendar.java


注:本文中的java.text.DateFormatSymbols.getWeekdays方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。