Java Month Name Get getMonthSelect(String selectName, String value, boolean hasBlank)

Here you can find the source of getMonthSelect(String selectName, String value, boolean hasBlank)

Description

get Month Select

License

Open Source License

Declaration

public static String getMonthSelect(String selectName, String value, boolean hasBlank) 

Method Source Code

//package com.java2s;

public class Main {

    public static String getMonthSelect(String selectName, String value, boolean hasBlank) {
        StringBuffer sb = new StringBuffer("");
        sb.append("<select name=\"" + selectName + "\">");
        if (hasBlank) {
            sb.append("<option value=\"\"></option>");
        }// www .j a  v a2 s  .  co m
        for (int i = 1; i <= 12; i++) {
            if (!value.trim().equals("") && i == Integer.parseInt(value)) {
                sb.append("<option value=\"" + i + "\" selected>" + i + "</option>");
            } else {
                sb.append("<option value=\"" + i + "\">" + i + "</option>");
            }
        }
        sb.append("</select>");
        return sb.toString();
    }

    public static String getMonthSelect(String selectName, String value, boolean hasBlank, String js) {
        StringBuffer sb = new StringBuffer("");
        sb.append("<select name=\"" + selectName + "\" " + js + ">");
        if (hasBlank) {
            sb.append("<option value=\"\"></option>");
        }
        for (int i = 1; i <= 12; i++) {
            if (!value.trim().equals("") && i == Integer.parseInt(value)) {
                sb.append("<option value=\"" + i + "\" selected>" + i + "</option>");
            } else {
                sb.append("<option value=\"" + i + "\">" + i + "</option>");
            }
        }
        sb.append("</select>");
        return sb.toString();
    }
}

Related

  1. getMonthName(String code)
  2. getMonthName(String dateString)
  3. getMonthName(String month)
  4. getMonthNames(Locale locale)
  5. getMonthNames(Locale locale)
  6. getMonthStr(int month)
  7. getMonthStr(int month)
  8. getMonthStr(String str)
  9. getMonthString(int month)