0

I'm making a Date class for my school work which basically do some basic features just like API Date. Non of the methods are allowed to associate with the API Date class of Java except for one of the constructors which set to current local time. Then I made a method to change format based on input option. The code work pretty good however there's a miscalculate in month output for the format method. Perhaps I did the logic on the array wrong but could't figure out how to make it right.
For example: if I put 4/2/2019 and choose option B then it'd print "December 2 2019" instead of "April"

I tried month = 0 and 1 for the loop it dont work out.

```
import java.util.*;
public class Date
{
    // declare needed variables
   private int day;
   private int month;
   private int year;

   /**
    * Default constructor to set the date info to the current date 
    */
   public Date()
   {
       // I have trouble assign Date using the Java API Date class
       Date d1 = new Date();
       Calendar cal = Calendar.getInstance();
       cal.setTime(d1);
       day= cal.get(Calendar.DAY_OF_MONTH);
       month = cal.get(Calendar.MONTH);
       year = cal.get(Calendar.YEAR);
    }
    /**
    * Overloaded constructor to set the date info based on user input
    * @param int inMonth to input month value
    * @param int inDay to input day value
    * @param int inYear to input year value
    *
    */
    public Date( int inMonth, int inDay, int inYear)
    {
       //set all the inputs into suitable variables
       day = inDay;
       month = inMonth;
       year = inYear;
    }
    public String getDate(char format)
    {
        //String Array for option B

        String[] mArray = {"January","Febuary","March","April","May","June","July","August","September","October","November","December"};
        String dayString = new String();
        //Switch code with param input format option and return the String based on it
        switch(format)
        {
            case 'A':
                dayString = month+"/"+day+"/"+year;
            break;
            case 'B':
            for(month = 1;month<mArray.length;month++)
            {

                dayString = mArray[month]+" "+day+" "+year;
            }
            break;
        }
        return dayString;
    }
    /**
    * ToString method to return date info
    * @return String of Date
    */
     public String toString()
    {
        //Return value of Date in String
        return month+"/"+day+"/"+year;
    }
}

```