title: How to replace if-else "months" code to "months" from enum's?
body: <p>I'm trying to replace my if-else statement with the enum code I just created on other .java file.
  However Im not sure how can I replace it with the enum code provided below. Since the if-else code feels repetitive and I thought maybe enum can help shorten the Main.java file.</p>
  <p>Main.java</p>
  <pre><code>if (month.equals(&quot;1&quot;)) {
              month = &quot;January&quot;;
          } else if (month.equals(&quot;2&quot;)) {
              month = &quot;February&quot;;
          } else if (month.equals(&quot;3&quot;)) {
              month = &quot;March&quot;;
          } else if (month.equals(&quot;4&quot;)) {
              month = &quot;April&quot;;
          } else if (month.equals(&quot;5&quot;)) {
              month = &quot;May&quot;;
          } else if (month.equals(&quot;6&quot;)) {
              month = &quot;June&quot;;
          } else if (month.equals(&quot;7&quot;)) {
              month = &quot;July&quot;;
          } else if (month.equals(&quot;8&quot;)) {
              month = &quot;August&quot;;
          } else if (month.equals(&quot;9&quot;)) {
              month = &quot;September&quot;;
          } else if (month.equals(&quot;10&quot;)) {
              month = &quot;October&quot;;
          } else if (month.equals(&quot;11&quot;)) {
              month = &quot;November&quot;;
          } else if (month.equals(&quot;12&quot;)) {
              month = &quot;December&quot;;
          }
  </code></pre>
  <p>Months.java (enum)</p>
  <pre><code>package enums;
  
  public enum Months {
    JANUARY(&quot;1&quot;, &quot;January&quot;),
    FEBRUARY(&quot;2&quot;, &quot;February&quot;),
    MARCH(&quot;3&quot;, &quot;March&quot;),
    APRIL(&quot;4&quot;, &quot;April&quot;),
    MAY(&quot;5&quot;, &quot;May&quot;),
    JUNE(&quot;6&quot;, &quot;June&quot;),
    JULY(&quot;7&quot;, &quot;July&quot;),
    AUGUST(&quot;8&quot;, &quot;August&quot;),
    SEPTEMBER(&quot;9&quot;, &quot;September&quot;),
    OCTOBER(&quot;10&quot;, &quot;October&quot;),
    NOVEMBER(&quot;11&quot;, &quot;November&quot;),
    DECEMBER(&quot;12&quot;, &quot;December&quot;);
  
    Months(String code, String description) {
      this.code = code;
      this.description = description;
    }
  
    private String code;
  
    private String description;
  
    public String getCode() {
      return code;
    }
  
    public String getDescription() {
      return description;
    }
  
    public static Months convertToEnum(String value) {
      Months m = null;
      for (Months month : Months.values()) {
        if (month.code.contentEquals(value)) {
          m = month;
        }
      }
      return m;
    }
  
    public static String convertToValue(Months item) {
      String value = &quot;&quot;;
      for (Months month : Months.values()) {
        if (month.equals(item)) {
          value = month.getCode();
        }
      }
      return value;
    }
  }
  </code></pre>