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


Java DateFormatSymbols.getMonths方法代码示例

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


在下文中一共展示了DateFormatSymbols.getMonths方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: MonthDateFormat

import java.text.DateFormatSymbols; //导入方法依赖的package包/类
/**
 * Creates a new formatter.
 *
 * @param zone  the time zone used to extract the month and year from dates
 *              passed to this formatter (<code>null</code> not permitted).
 * @param locale  the locale used to determine the month names
 *                (<code>null</code> not permitted).
 * @param chars  the maximum number of characters to use from the month
 *               names, or zero to indicate that the entire month name
 *               should be used.
 * @param showYear  an array of flags that control whether or not the
 *                  year is displayed for a particular month.
 * @param yearFormatter  the year formatter.
 */
public MonthDateFormat(TimeZone zone, Locale locale, int chars,
                       boolean[] showYear, DateFormat yearFormatter) {
    ParamChecks.nullNotPermitted(locale, "locale");
    DateFormatSymbols dfs = new DateFormatSymbols(locale);
    String[] monthsFromLocale = dfs.getMonths();
    this.months = new String[12];
    for (int i = 0; i < 12; i++) {
        if (chars > 0) {
            this.months[i] = monthsFromLocale[i].substring(0,
                    Math.min(chars, monthsFromLocale[i].length()));
        }
        else {
            this.months[i] = monthsFromLocale[i];
        }
    }
    this.calendar = new GregorianCalendar(zone);
    this.showYear = showYear;
    this.yearFormatter = yearFormatter;

    // the following is never used, but it seems that DateFormat requires
    // it to be non-null.  It isn't well covered in the spec, refer to
    // bug parade 5061189 for more info.
    this.numberFormat = NumberFormat.getNumberInstance();
}
 
开发者ID:mdzio,项目名称:ccu-historian,代码行数:39,代码来源:MonthDateFormat.java

示例3: MonthDateFormat

import java.text.DateFormatSymbols; //导入方法依赖的package包/类
/**
 * Creates a new formatter.
 *
 * @param zone  the time zone used to extract the month and year from dates
 *              passed to this formatter ({@code null} not permitted).
 * @param locale  the locale used to determine the month names
 *                ({@code null} not permitted).
 * @param chars  the maximum number of characters to use from the month
 *               names, or zero to indicate that the entire month name
 *               should be used.
 * @param showYear  an array of flags that control whether or not the
 *                  year is displayed for a particular month.
 * @param yearFormatter  the year formatter.
 */
public MonthDateFormat(TimeZone zone, Locale locale, int chars,
                       boolean[] showYear, DateFormat yearFormatter) {
    Args.nullNotPermitted(locale, "locale");
    DateFormatSymbols dfs = new DateFormatSymbols(locale);
    String[] monthsFromLocale = dfs.getMonths();
    this.months = new String[12];
    for (int i = 0; i < 12; i++) {
        if (chars > 0) {
            this.months[i] = monthsFromLocale[i].substring(0,
                    Math.min(chars, monthsFromLocale[i].length()));
        }
        else {
            this.months[i] = monthsFromLocale[i];
        }
    }
    this.calendar = new GregorianCalendar(zone);
    this.showYear = showYear;
    this.yearFormatter = yearFormatter;

    // the following is never used, but it seems that DateFormat requires
    // it to be non-null.  It isn't well covered in the spec, refer to
    // bug parade 5061189 for more info.
    this.numberFormat = NumberFormat.getNumberInstance();
}
 
开发者ID:jfree,项目名称:jfreechart,代码行数:39,代码来源:MonthDateFormat.java

示例4: getStandaloneMonthName

import java.text.DateFormatSymbols; //导入方法依赖的package包/类
/**
 * getStandaloneMonthName, This returns a "standalone version" month name for the specified
 * month, in the specified locale. In some languages, including Russian and Czech, the
 * standalone version of the month name is different from the version of the month name you
 * would use as part of a full date. (Is different from the formatting version).
 *
 * This tries to get the standalone version first. If no mapping is found for a standalone
 * version (Presumably because the supplied language has no standalone version), then this will
 * return the formatting version of the month name.
 */
private static String getStandaloneMonthName(Month month, Locale locale, boolean capitalize,
        boolean shortVersion) {
    // Attempt to get the standalone version of the month name.
    TextStyle style = (shortVersion) ? TextStyle.SHORT_STANDALONE : TextStyle.FULL_STANDALONE;
    String monthName = month.getDisplayName(style, locale);
    String monthNumber = "" + month.getValue();
    // If no mapping was found, then get the "formatting version" of the month name.
    if (monthName.equals(monthNumber)) {
        DateFormatSymbols dateSymbols = DateFormatSymbols.getInstance(locale);
        if (shortVersion) {
            monthName = dateSymbols.getShortMonths()[month.getValue() - 1];
        } else {
            monthName = dateSymbols.getMonths()[month.getValue() - 1];
        }
    }
    // If needed, capitalize the month name.
    if ((capitalize) && (monthName != null) && (monthName.length() > 0)) {
        monthName = monthName.substring(0, 1).toUpperCase(locale) + monthName.substring(1);
    }
    return monthName;
}
 
开发者ID:LGoodDatePicker,项目名称:LGoodDatePicker,代码行数:32,代码来源:ExtraDateStrings.java

示例5: getFormattingMonthName

import java.text.DateFormatSymbols; //导入方法依赖的package包/类
/**
 * getFormattingMonthName, This returns a "formatting version" month name for the specified
 * month, in the specified locale. In some languages, including Russian and Czech, the
 * standalone version of the month name is different from the version of the month name you
 * would use as part of a full date. (Is different from the formatting version).
 */
private static String getFormattingMonthName(Month month, Locale locale, boolean capitalize,
        boolean shortVersion) {
    // Get the "formatting version" of the month name.
    DateFormatSymbols dateSymbols = DateFormatSymbols.getInstance(locale);
    String monthName;
    if (shortVersion) {
        monthName = dateSymbols.getShortMonths()[month.getValue() - 1];
    } else {
        monthName = dateSymbols.getMonths()[month.getValue() - 1];
    }
    // If needed, capitalize the month name.
    if ((capitalize) && (monthName != null) && (monthName.length() > 0)) {
        monthName = monthName.substring(0, 1).toUpperCase(locale) + monthName.substring(1);
    }
    return monthName;
}
 
开发者ID:LGoodDatePicker,项目名称:LGoodDatePicker,代码行数:23,代码来源:ExtraDateStrings.java

示例6: getCurrentMonth

import java.text.DateFormatSymbols; //导入方法依赖的package包/类
public static String getCurrentMonth(int monthIndex) {
    final Calendar calendar = Calendar.getInstance(Locale.getDefault());
    final DateFormatSymbols dateFormat = new DateFormatSymbols(Locale.getDefault());
    calendar.add(Calendar.MONTH, monthIndex);

    return dateFormat.getMonths()[calendar.get(Calendar.MONTH)];
}
 
开发者ID:DSM-DMS,项目名称:DMS,代码行数:8,代码来源:CalendarUtility.java

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

示例8: MonthDateFormat

import java.text.DateFormatSymbols; //导入方法依赖的package包/类
/**
 * Creates a new formatter.
 * 
 * @param zone  the time zone used to extract the month and year from dates
 *              passed to this formatter (<code>null</code> not permitted).
 * @param locale  the locale used to determine the month names 
 *                (<code>null</code> not permitted).
 * @param chars  the maximum number of characters to use from the month 
 *               names, or zero to indicate that the entire month name 
 *               should be used.
 * @param showYear  an array of flags that control whether or not the
 *                  year is displayed for a particular month.
 * @param yearFormatter  the year formatter.
 */
public MonthDateFormat(TimeZone zone, Locale locale, int chars, 
                       boolean[] showYear, DateFormat yearFormatter) {
    if (locale == null) {
        throw new IllegalArgumentException("Null 'locale' argument.");
    }
    DateFormatSymbols dfs = new DateFormatSymbols(locale);
    String[] monthsFromLocale = dfs.getMonths();
    this.months = new String[12];
    for (int i = 0; i < 12; i++) {
        if (chars > 0) {
            months[i] = monthsFromLocale[i].substring(0, 
                    Math.min(chars, monthsFromLocale[i].length()));
        }
        else {
            months[i] = monthsFromLocale[i];
        }
    }
    this.calendar = new GregorianCalendar(zone);
    this.showYear = showYear;
    this.yearFormatter = yearFormatter; 
    
    // the following is never used, but it seems that DateFormat requires
    // it to be non-null.  It isn't well covered in the spec, refer to 
    // bug parade 5061189 for more info.
    this.numberFormat = NumberFormat.getNumberInstance();
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:41,代码来源:MonthDateFormat.java

示例9: getMonthForInt

import java.text.DateFormatSymbols; //导入方法依赖的package包/类
String getMonthForInt(int num) {
    String month = "wrong";
    DateFormatSymbols dfs = new DateFormatSymbols();
    String[] months = dfs.getMonths();
    if (num >= 0 && num <= 11) {
        month = months[num];
    }
    return month;
}
 
开发者ID:tsoglani,项目名称:SpeechRaspberrySmartHouse,代码行数:10,代码来源:Jarvis.java

示例10: setSizeOfMonthYearPanel

import java.text.DateFormatSymbols; //导入方法依赖的package包/类
/**
 * setSizeOfMonthYearPanel, This sets the size of the panel at the top of the calendar that
 * holds the month and the year label. The size is calculated from the largest month name (in
 * pixels), that exists in locale and language that is being used by the date picker.
 */
private void setSizeOfMonthYearPanel() {
    // Skip this function if the settings have not been applied.
    if (settings == null) {
        return;
    }
    // Get the font metrics object.
    Font font = labelMonth.getFont();
    Canvas canvas = new Canvas();
    FontMetrics metrics = canvas.getFontMetrics(font);
    // Calculate the preferred height for the month and year panel.
    int heightNavigationButtons = buttonPreviousYear.getPreferredSize().height;
    int preferredHeightMonthLabel = labelMonth.getPreferredSize().height;
    int preferredHeightYearLabel = labelYear.getPreferredSize().height;
    int monthFontHeight = metrics.getHeight();
    int monthFontHeightWithPadding = monthFontHeight + 2;
    int panelHeight = Math.max(monthFontHeightWithPadding, Math.max(preferredHeightMonthLabel,
            Math.max(preferredHeightYearLabel, heightNavigationButtons)));
    // Get the length of the longest translated month string (in pixels).
    DateFormatSymbols symbols = DateFormatSymbols.getInstance(settings.getLocale());
    String[] allLocalMonths = symbols.getMonths();
    int longestMonthPixels = 0;
    for (String month : allLocalMonths) {
        int monthPixels = metrics.stringWidth(month);
        longestMonthPixels = (monthPixels > longestMonthPixels) ? monthPixels : longestMonthPixels;
    }
    int yearPixels = metrics.stringWidth("_2000");
    // Calculate the size of a box to hold the text with some padding.
    Dimension size = new Dimension(longestMonthPixels + yearPixels + 12, panelHeight);
    // Set the monthAndYearPanel to the appropriate constant size.
    monthAndYearOuterPanel.setMinimumSize(size);
    monthAndYearOuterPanel.setPreferredSize(size);
    // monthAndYearOuterPanel.setMaximumSize(size);
    // Redraw the panel.
    this.doLayout();
    this.validate();
}
 
开发者ID:LGoodDatePicker,项目名称:LGoodDatePicker,代码行数:42,代码来源:CalendarPanel.java

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

示例12: getMonthForInt

import java.text.DateFormatSymbols; //导入方法依赖的package包/类
public static String getMonthForInt(int num) {
    String month = "wrong";
    DateFormatSymbols dfs = new DateFormatSymbols();
    String[] months = dfs.getMonths();
    if (num >= 0 && num <= 11) {
        month = months[num];
    }
    return month;
}
 
开发者ID:korena,项目名称:service-base,代码行数:10,代码来源:Utilities.java

示例13: DateMonthCalculator

import java.text.DateFormatSymbols; //导入方法依赖的package包/类
public DateMonthCalculator(String baseColumnName, String columnName) {
	super(baseColumnName, columnName);
    DateFormatSymbols dfs = new DateFormatSymbols();
    this.months = dfs.getMonths();
}
 
开发者ID:activeviam,项目名称:autopivot,代码行数:6,代码来源:DateMonthCalculator.java

示例14: layoutCalendar

import java.text.DateFormatSymbols; //导入方法依赖的package包/类
private void layoutCalendar() {
    final FormLayout formLayout = new FormLayout();
    formLayout.spacing = 0;
    setLayout(formLayout);

    // create the date objects
    for (int i = 0; i < rows; i++) {
        for (int j = 0; j <= (lastDayOfWeek - firstDayOfWeek); j++) {
            dayControl[i][j] = new DatepickerDate(this, SWT.NONE);
        }
    }

    if (WindowSystem.isCurrentWindowSystem(WindowSystem.AQUA)) {
        layoutHeaderMacOSX();
    } else {
        layoutHeaderOther();
    }

    /*
     * find the largest width possible for the month label and set the width
     * of the label to that.
     */
    final GC gc = new GC(getDisplay());
    gc.setFont(monthLabel.getFont());

    final DateFormatSymbols dateSymbols = new DateFormatSymbols();
    final String monthSymbols[] = dateSymbols.getMonths();
    int monthLabelWidth = 0;

    for (int i = 0; i < monthSymbols.length; i++) {
        final String monthText =
            MessageFormat.format(
                Messages.getString("Datepicker.HeaderStringMonthSpaceYearFormat"), //$NON-NLS-1$
                monthSymbols[i],
                "9999"); //$NON-NLS-1$
        monthLabel.setText(monthText);

        monthLabelWidth = Math.max(monthLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, monthLabelWidth);
    }

    ((FormData) monthLabel.getLayoutData()).width = monthLabelWidth;

    // lay out the dayControls
    for (int i = 0; i < rows; i++) {
        for (int j = 0; j <= (lastDayOfWeek - firstDayOfWeek); j++) {
            final FormData blankControlData = new FormData();
            blankControlData.top = (i == 0) ? new FormAttachment(headerBottom, 0, SWT.BOTTOM)
                : new FormAttachment(dayControl[(i - 1)][0], spacing.y, SWT.BOTTOM);
            blankControlData.left = (j == 0) ? new FormAttachment(0, 0)
                : new FormAttachment(dayControl[i][(j - 1)], spacing.x, SWT.RIGHT);
            dayControl[i][j].setLayoutData(blankControlData);
            dayControl[i][j].setFont(font);
            dayControl[i][j].setAlignment(dayAlignment);

            if (j == 0) {
                dayControl[i][j].setShape(DatepickerDate.SHAPE_LEFT);
            } else if (j == (lastDayOfWeek - firstDayOfWeek)) {
                dayControl[i][j].setShape(DatepickerDate.SHAPE_RIGHT);
            }

            dayControl[i][j].addMouseListener(this);
            dayControl[i][j].addMouseMoveListener(this);
            dayControl[i][j].addKeyListener(this);
        }
    }

    layout(true);
    pack();
}
 
开发者ID:Microsoft,项目名称:team-explorer-everywhere,代码行数:70,代码来源:Datepicker.java

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