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


Java DateFormatSymbols类代码示例

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


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

示例1: WeekAdapter

import java.text.DateFormatSymbols; //导入依赖的package包/类
public WeekAdapter(Context context){
    this.context = context;

    this.list = new ArrayList<>();
    String[] weekdays = new DateFormatSymbols().getWeekdays();
    this.list.add(weekdays[Calendar.SUNDAY]);
    this.list.add(weekdays[Calendar.MONDAY]);
    this.list.add(weekdays[Calendar.TUESDAY]);
    this.list.add(weekdays[Calendar.WEDNESDAY]);
    this.list.add(weekdays[Calendar.THURSDAY]);
    this.list.add(weekdays[Calendar.FRIDAY]);
    this.list.add(weekdays[Calendar.SATURDAY]);

    for(int i = 0; i < list.size(); i++) {
        setIsSelected(i, false);
    }
}
 
开发者ID:mainh,项目名称:MainCalendar,代码行数:18,代码来源:WeekAdapter.java

示例2: 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

示例3: _getWrongWeekDayMessage

import java.text.DateFormatSymbols; //导入依赖的package包/类
/**
 * Builds an error message indicating invalid week-day selection
 * @param context FacesContext
 * @param component inputDate instance
 * @param converter date converter instance
 * @param value user submitted value
 * @param dayOfTheWeekIndex Week day index as returned by Calendar.DAY_OF_WEEK on the value
 * @return FacesMessage
 */
private FacesMessage _getWrongWeekDayMessage(
  FacesContext  context,
  UIComponent   component,
  Converter     converter,
  Object        value,
  int           dayOfTheWeekIndex)
{ 
  RequestContext reqContext = RequestContext.getCurrentInstance();      
  Locale locale = reqContext.getFormattingLocale();

  if (locale == null)
  {
    locale = context.getViewRoot().getLocale();
  }
    
  Object cValue = _getConvertedValue(context, component, converter, value);
  Object msg   = _getRawInvalidDaysOfWeekMessageDetail();
  Object label = ValidatorUtils.getComponentLabel(component);
  String[] weekdays = new DateFormatSymbols(locale).getWeekdays();

  // Fetch the localized week name 
  Object[] params = {label, cValue, weekdays[dayOfTheWeekIndex]};

  return MessageFactory.getMessage(context, WEEKDAY_MESSAGE_ID, msg, params, component);
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:35,代码来源:DateRestrictionValidator.java

示例4: ButtonTextModel

import java.text.DateFormatSymbols; //导入依赖的package包/类
ButtonTextModel(@NonNull LocaleModel localeModel, boolean is24HourMode) {
    final String timeSeparator = localeModel.getTimeSeparator(is24HourMode);
    String leftAltText, rightAltText;
    if (is24HourMode) {
        leftAltText = String.format("%02d", 0);
        rightAltText = String.format("%02d", 30);
        leftAltText = localeModel.isLayoutRtl() ?
                (leftAltText + timeSeparator) : (timeSeparator + leftAltText);
        rightAltText = localeModel.isLayoutRtl() ?
                (rightAltText + timeSeparator) : (timeSeparator + rightAltText);
    } else {
        String[] amPm = new DateFormatSymbols().getAmPmStrings();
        // TODO: Get localized. Or get the same am/pm strings as the framework.
        leftAltText = amPm[0].length() > 2 ? "AM" : amPm[0];
        rightAltText = amPm[1].length() > 2 ? "PM" : amPm[1];
    }
    mAltButtonsTexts[0] = leftAltText;
    mAltButtonsTexts[1] = rightAltText;
    mIs24HourMode = is24HourMode;
}
 
开发者ID:philliphsu,项目名称:NumberPadTimePicker,代码行数:21,代码来源:ButtonTextModel.java

示例5: setupWeekDaysPref

import java.text.DateFormatSymbols; //导入依赖的package包/类
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);
    }
}
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:18,代码来源:QuietHoursActivity.java

示例6: parseText

import java.text.DateFormatSymbols; //导入依赖的package包/类
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);
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:18,代码来源:TestZoneTextPrinterParser.java

示例7: main

import java.text.DateFormatSymbols; //导入依赖的package包/类
public static void main(String[] args) {

        List<String> listNotFound = new ArrayList<>();
        String[][] zoneStrings = DateFormatSymbols.getInstance()
                .getZoneStrings();
        for (String tzID : TimeZone.getAvailableIDs()) {
            if (!Arrays.stream(zoneStrings)
                    .anyMatch(zone -> tzID.equalsIgnoreCase(zone[0]))) {
                // to ignore names for Etc/GMT[+-][0-9]+ which are not supported
                // Also ignore the TimeZone DisplayNames with GMT[+-]:hh:mm
                if (!tzID.startsWith("Etc/GMT")
                        && !tzID.startsWith("GMT")
                        && !TimeZone.getTimeZone(tzID).getDisplayName().startsWith("GMT")) {
                    listNotFound.add(tzID);
                }
            }
        }

        if (!listNotFound.isEmpty()) {
            throw new RuntimeException("Test Failed: Time Zone Strings for "
                    + listNotFound + " not found");
        }

    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:Bug8149452.java

示例8: testEraName

import java.text.DateFormatSymbols; //导入依赖的package包/类
/**
 * tests that era names retrieved from Calendar.getDisplayNames map should
 * match with that of Era names retrieved from DateFormatSymbols.getEras()
 * method for all Gregorian Calendar locales .
 */
public static void testEraName() {
    Set<Locale> allLocales = Set.of(Locale.getAvailableLocales());
    Set<Locale> JpThlocales = Set.of(
            new Locale("th", "TH"),
            new Locale("ja", "JP", "JP"), new Locale("th", "TH", "TH")
    );
    Set<Locale> allLocs = new HashSet<>(allLocales);
    // Removing Japense and Thai Locales to check  Gregorian Calendar Locales
    allLocs.removeAll(JpThlocales);
    allLocs.forEach((locale) -> {
        Calendar cal = Calendar.getInstance(locale);
        Map<String, Integer> names = cal.getDisplayNames(Calendar.ERA, Calendar.ALL_STYLES, locale);
        DateFormatSymbols symbols = new DateFormatSymbols(locale);
        String[] eras = symbols.getEras();
        for (String era : eras) {
            if (!names.containsKey(era)) {
                reportMismatch(names.keySet(), eras, locale);
            }
        }
    });
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:Bug8167273.java

示例9: testEmptyEraNames

import java.text.DateFormatSymbols; //导入依赖的package包/类
/**
 * tests that Eras names returned from DateFormatSymbols.getEras()
 * and Calendar.getDisplayNames() should not be empty for any Locale.
 */
private static void testEmptyEraNames() {
    Set<Locale> allLocales = Set.of(Locale.getAvailableLocales());
    allLocales.forEach((loc) -> {
        DateFormatSymbols dfs = new DateFormatSymbols(loc);
        Calendar cal = Calendar.getInstance(loc);
        Map<String, Integer> names = cal.getDisplayNames(Calendar.ERA, Calendar.ALL_STYLES, loc);
        Set<String> CalendarEraNames = names.keySet();
        String[] eras = dfs.getEras();
        for (String era : eras) {
            if (era.isEmpty()) {
                throw new RuntimeException("Empty era names retrieved for DateFomatSymbols.getEras"
                        + " for locale " + loc);
            }
        }
        CalendarEraNames.stream().filter((erakey) -> (erakey.isEmpty())).forEachOrdered((l) -> {
            throw new RuntimeException("Empty era names retrieved for Calendar.getDisplayName"
                    + " for locale " + loc);
        });
    });

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:Bug8167273.java

示例10: main

import java.text.DateFormatSymbols; //导入依赖的package包/类
public static void main(String[] args) {
    List<Locale> avail = Arrays.asList(BreakIterator.getAvailableLocales());
    diffLocale(BreakIterator.class, avail);

    avail = Arrays.asList(Collator.getAvailableLocales());
    diffLocale(Collator.class, avail);

    avail = Arrays.asList(DateFormat.getAvailableLocales());
    diffLocale(DateFormat.class, avail);

    avail = Arrays.asList(DateFormatSymbols.getAvailableLocales());
    diffLocale(DateFormatSymbols.class, avail);

    avail = Arrays.asList(DecimalFormatSymbols.getAvailableLocales());
    diffLocale(DecimalFormatSymbols.class, avail);

    avail = Arrays.asList(NumberFormat.getAvailableLocales());
    diffLocale(NumberFormat.class, avail);

    avail = Arrays.asList(Locale.getAvailableLocales());
    diffLocale(Locale.class, avail);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:Bug8001562.java

示例11: show

import java.text.DateFormatSymbols; //导入依赖的package包/类
/**
 * Metoda pokazująca widżet dla podanej strefy czasowej.
 *
 * @param timezone strefa czasowa.
 */
public void show(String timezone) {
    clock.setTimeZone(timezone);
    clock.setFormat24Hour(clock.getFormat24Hour());
    clock.setFormat12Hour(null);
    Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone(timezone));
    String[] dayNames = new DateFormatSymbols(new Locale("pl")).getWeekdays();
    String[] monthNames = new DateFormatSymbols(new Locale("pl")).getMonths();
    date.setText(String.format(context.getString(R.string.date_format), dayNames[calendar.get(Calendar.DAY_OF_WEEK)],
            Integer.toString(calendar.get(Calendar.DAY_OF_MONTH)),
            monthNames[calendar.get(Calendar.MONTH)]));
    YoYo.with(Techniques.ZoomIn)
            .onStart(new YoYo.AnimatorCallback() {
                @Override
                public void call(Animator animator) {
                    setVisibility(VISIBLE);
                }
            })
            .playOn(this);
}
 
开发者ID:hypeapps,项目名称:black-mirror,代码行数:25,代码来源:TimeWidgetView.java

示例12: RepeatPreference

import java.text.DateFormatSymbols; //导入依赖的package包/类
public RepeatPreference(Context context, AttributeSet attrs) {
  super(context, attrs);

  String[] weekdays = new DateFormatSymbols().getWeekdays();
  String[] values = new String[]{
      weekdays[Calendar.MONDAY],
      weekdays[Calendar.TUESDAY],
      weekdays[Calendar.WEDNESDAY],
      weekdays[Calendar.THURSDAY],
      weekdays[Calendar.FRIDAY],
      weekdays[Calendar.SATURDAY],
      weekdays[Calendar.SUNDAY],};
  setEntries(values);
  setEntryValues(values);
}
 
开发者ID:nordfalk,项目名称:EsperantoRadio,代码行数:16,代码来源:RepeatPreference.java

示例13: getAmPmStrings

import java.text.DateFormatSymbols; //导入依赖的package包/类
static String[] getAmPmStrings(Context context) {
    final Locale locale = context.getResources().getConfiguration().locale;
    /*final LocaleData d = LocaleData.get(locale);

    final String[] result = new String[2];
    result[0] = d.amPm[0].length() > 4 ? d.narrowAm : d.amPm[0];
    result[1] = d.amPm[1].length() > 4 ? d.narrowPm : d.amPm[1];
    return result;*/

    final String[] result = new String[2];
    final String[] amPm;

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        amPm = android.icu.text.DateFormatSymbols.getInstance(locale).getAmPmStrings();
    } else {
        amPm = DateFormatSymbols.getInstance(locale).getAmPmStrings();
    }

    result[0] = amPm[0].length() > 4 ? amPm[0].substring(0, 1) : amPm[0];
    result[1] = amPm[1].length() > 4 ? amPm[1].substring(0, 1) : amPm[1];

    return result;
}
 
开发者ID:Gericop,项目名称:DateTimePicker,代码行数:24,代码来源:TimePicker.java

示例14: setCurrentLocale

import java.text.DateFormatSymbols; //导入依赖的package包/类
/**
 * 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);
        }
    }
}
 
开发者ID:Gericop,项目名称:DateTimePicker,代码行数:27,代码来源:DatePickerSpinnerDelegate.java

示例15: setCellHeaderWeekDays

import java.text.DateFormatSymbols; //导入依赖的package包/类
public static void setCellHeaderWeekDays(final RemoteViews headerRowRv, final int firstDayOfWeek, final Context context) {

        DateFormatSymbols dfs = DateFormatSymbols.getInstance();
        String[] weekdays = dfs.getShortWeekdays();

        ThemesUtil.Theme theme = ConfigurationUtil.getTheme(context);

        for (int i = 0; i < Calendar.DAY_OF_WEEK; i++) {

            RemoteViews rv;
            int current = (firstDayOfWeek + i) % Calendar.DAY_OF_WEEK == 0 ? firstDayOfWeek + i : (firstDayOfWeek + i) % Calendar.DAY_OF_WEEK;
            if (current == Calendar.SATURDAY) {
                rv = setSpecificWeekDay(context, weekdays[current], theme.getCellHeaderSaturday());
            } else if (current == Calendar.SUNDAY) {
                rv = setSpecificWeekDay(context, weekdays[current], theme.getCellHeaderSunday());
            } else {
                rv = setSpecificWeekDay(context, weekdays[current], theme.getCellHeader());
            }
            headerRowRv.addView(R.id.row_container, rv);
        }
    }
 
开发者ID:mvmike,项目名称:min-cal-widget,代码行数:22,代码来源:WeekDayHeaderUtil.java


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