當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。