I've been working on a program for my Computer Programming class and I'm having a little trouble. Truthfully, I'm on the verge of insanity...
Its a calendar program and the part I'm having trouble with is the Calendar object in java. Here is my code for one of methods:
public static void calendarGet(){
String md = getInput("What date would you like to look at?(mm/dd)");
int slash = md.indexOf('/');
MDFromDate(md);
cal.set(cal.MONTH, MONTH - 1);
cal.set(cal.DATE, DAY);
TARGET_DAY = DAY;
MAX_DAY = cal.getActualMaximum(cal.DAY_OF_MONTH);
WEEKS_IN_MONTH = MAX_DAY / 7;
System.out.println(cal.MONTH + 1);
System.out.println(cal.DAY_OF_MONTH);
System.out.println(cal.getTime());
drawMonth(cal.MONTH);
}
And the output for this is:
What date would you like to look at?(mm/dd)12/12
3
5
Wed Dec 12 22:47:32 PST 2018
As you can see, if I use getTime(); it returns the right month and day but cal.MONTH and cal.DAY_OF_MONTH do not.
Also, when I use the debugger and look in cal, none of the variables had changed.
I'm incredibly confused, I would appreciate some help! :D
EDIT:
public static String getInput(String prompt){
System.out.print(prompt);
Scanner inScan = new Scanner(System.in);
return inScan.nextLine();
}
public static void MDFromDate(String md){
Scanner getMD = new Scanner(md).useDelimiter("/");
MONTH = getMD.nextInt();
DAY = getMD.nextInt();
}