Example usage for java.text DateFormatSymbols getMonths

List of usage examples for java.text DateFormatSymbols getMonths

Introduction

In this page you can find the example usage for java.text DateFormatSymbols getMonths.

Prototype

public String[] getMonths() 

Source Link

Document

Gets month strings.

Usage

From source file:com.qtplaf.library.util.Calendar.java

/**
 * Returns an array of localized names of months.
 *
 * @return An array of names.//from ww w  . j a v  a  2 s.co  m
 * @param locale The desired locale.
 * @param capitalized A boolean to capitalize the name.
 */
public static String[] getLongMonths(Locale locale, boolean capitalized) {

    DateFormatSymbols sysd = new DateFormatSymbols(locale);
    String[] dsc = sysd.getMonths();
    if (capitalized) {
        for (int i = 0; i < dsc.length; i++) {
            dsc[i] = StringUtils.capitalize(dsc[i]);
        }
    }
    return dsc;
}

From source file:com.erudika.para.utils.Utils.java

/**
 * Returns an array of the months in the Gregorian calendar.
 * @param locale the locale used for the months' names
 * @return an array of the 12 months/*from   w  w  w  . j a  v a 2  s .  c o  m*/
 */
public static String[] getMonths(Locale locale) {
    if (locale == null) {
        locale = Locale.US;
    }
    DateFormatSymbols dfs = DateFormatSymbols.getInstance(locale);
    return dfs.getMonths();
}

From source file:com.inkubator.hrm.web.converter.MonthNumberAsStringConverter.java

@Override
public String getAsString(FacesContext context, UIComponent component, Object value) {
    String monthAsString = StringUtils.EMPTY;
    String data = value.toString();

    if (StringUtils.isNumeric(data)) {
        Integer month = Integer.valueOf(data);
        DateFormatSymbols dfs = new DateFormatSymbols(
                new Locale(FacesUtil.getSessionAttribute(HRMConstant.BAHASA_ACTIVE).toString()));
        monthAsString = dfs.getMonths()[month - 1];
    }/*  w w w .j  a v a2s .co  m*/

    return monthAsString;
}

From source file:com.application.utils.FastDateParser.java

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();
    }/* w  ww. j av  a  2  s  .com*/
    return null;
}

From source file:org.shredzone.cilla.site.renderer.CalendarRenderStrategyImpl.java

/**
 * Writes the caption line. It consists of the month name, the year, and links to the
 * previous and next month.// w ww  .  j  a va2  s . co  m
 */
protected void writeCaption() throws IOException {
    Calendar cal = generator.getDisplayCalendar();

    DateFormatSymbols symbols = DateFormatSymbols.getInstance(generator.getLocale());
    String[] months = symbols.getMonths();

    out.append("<caption>");
    writePreviousLink();
    out.append(months[cal.get(Calendar.MONTH)]);
    out.append(' ');
    out.append(String.valueOf(cal.get(Calendar.YEAR)));
    writeNextLink();
    out.append("</caption>");
}

From source file:forge.screens.deckeditor.DeckImport.java

/**
 * TODO: Write javadoc for this method.//  w ww.  java  2s  .  co  m
 */
private void fillDateDropdowns() {
    DateFormatSymbols dfs = new DateFormatSymbols();
    monthDropdown.removeAllItems();
    String[] months = dfs.getMonths();
    for (String monthName : months)
        if (!StringUtils.isBlank(monthName))
            monthDropdown.addItem(monthName);
    int yearNow = Calendar.getInstance().get(Calendar.YEAR);
    for (int i = yearNow; i >= 1993; i--)
        yearDropdown.addItem(Integer.valueOf(i));
}

From source file:org.apache.myfaces.custom.calendar.HtmlCalendarRenderer.java

public static String[] mapMonths(DateFormatSymbols symbols) {
    String[] months = new String[12];

    String[] localeMonths = symbols.getMonths();

    months[0] = localeMonths[Calendar.JANUARY];
    months[1] = localeMonths[Calendar.FEBRUARY];
    months[2] = localeMonths[Calendar.MARCH];
    months[3] = localeMonths[Calendar.APRIL];
    months[4] = localeMonths[Calendar.MAY];
    months[5] = localeMonths[Calendar.JUNE];
    months[6] = localeMonths[Calendar.JULY];
    months[7] = localeMonths[Calendar.AUGUST];
    months[8] = localeMonths[Calendar.SEPTEMBER];
    months[9] = localeMonths[Calendar.OCTOBER];
    months[10] = localeMonths[Calendar.NOVEMBER];
    months[11] = localeMonths[Calendar.DECEMBER];

    return months;
}

From source file:com.icesoft.faces.component.selectinputdate.SelectInputDateRenderer.java

/**
 * @param symbols//from w w w  . j a  v  a  2s . co m
 * @return months - String[] containing localized month names
 */
public static String[] mapMonths(DateFormatSymbols symbols) {
    String[] months = new String[12];

    String[] localeMonths = symbols.getMonths();

    months[0] = localeMonths[Calendar.JANUARY];
    months[1] = localeMonths[Calendar.FEBRUARY];
    months[2] = localeMonths[Calendar.MARCH];
    months[3] = localeMonths[Calendar.APRIL];
    months[4] = localeMonths[Calendar.MAY];
    months[5] = localeMonths[Calendar.JUNE];
    months[6] = localeMonths[Calendar.JULY];
    months[7] = localeMonths[Calendar.AUGUST];
    months[8] = localeMonths[Calendar.SEPTEMBER];
    months[9] = localeMonths[Calendar.OCTOBER];
    months[10] = localeMonths[Calendar.NOVEMBER];
    months[11] = localeMonths[Calendar.DECEMBER];

    return months;
}

From source file:org.sparkcommerce.core.web.processor.OnePageCheckoutProcessor.java

/**
 * A helper method used to construct a list of Credit Card Expiration Months
 * Useful for expiration dropdown menus.
 * Will use locale to determine language if a locale is available.
 *
 * @return List containing expiration months of the form "01 - January"
 *///from w  w w  .  ja va  2 s.c  o  m
protected List<String> populateExpirationMonths() {
    DateFormatSymbols dateFormatter;
    if (SparkRequestContext.hasLocale()) {
        Locale locale = SparkRequestContext.getSparkRequestContext().getJavaLocale();
        dateFormatter = new DateFormatSymbols(locale);
    } else {
        dateFormatter = new DateFormatSymbols();
    }
    List<String> expirationMonths = new ArrayList<String>();
    NumberFormat formatter = new DecimalFormat("00");
    String[] months = dateFormatter.getMonths();
    for (int i = 1; i < months.length; i++) {
        expirationMonths.add(formatter.format(i) + " - " + months[i - 1]);
    }
    return expirationMonths;
}

From source file:org.broadleafcommerce.core.web.processor.OnePageCheckoutProcessor.java

/**
 * A helper method used to construct a list of Credit Card Expiration Months
 * Useful for expiration dropdown menus.
 * Will use locale to determine language if a locale is available.
 *
 * @return List containing expiration months of the form "01 - January"
 *///  w  w  w.  j a  va  2  s  .  c  o m
protected List<String> populateExpirationMonths() {
    DateFormatSymbols dateFormatter;
    if (BroadleafRequestContext.hasLocale()) {
        Locale locale = BroadleafRequestContext.getBroadleafRequestContext().getJavaLocale();
        dateFormatter = new DateFormatSymbols(locale);
    } else {
        dateFormatter = new DateFormatSymbols();
    }
    List<String> expirationMonths = new ArrayList<String>();
    NumberFormat formatter = new DecimalFormat("00");
    String[] months = dateFormatter.getMonths();
    for (int i = 1; i < months.length; i++) {
        expirationMonths.add(formatter.format(i) + " - " + months[i - 1]);
    }
    return expirationMonths;
}