I am trying to retrieve the date format depending on the month, day and year the user enters. It should be called from one function and the logic in another. When I run the code, the questions run but the date is not outputted even though it is being returned to the getArrivalDate method. Any ideas?
CODE:
import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;
import java.util.Scanner;
import java.time.LocalDateTime;
import java.time.Month;
import java.text.NumberFormat;
import java.time.LocalDate;
public class Reserve {
public static void main(String[] args) {
System.out.println("Enter the requested input");
System.out.println();
//Call Arrival Date Method
getArrivalDate();
}
public static void getArrivalDate() {
// create a Scanner object
Scanner sc = new Scanner(System.in);
String choice = "y";
while (choice.equalsIgnoreCase("y")) {
System.out.print("month (1-12): ");
int month = sc.nextInt();
System.out.print("day (1-31): ");
int day = sc.nextInt();
System.out.print("year: ");
int year = sc.nextInt();
setArrivalDate(choice);
//Users choice
choice = sc.nextLine();
}
} //End getArrivalDate
public static String setArrivalDate(String arrivalDate1) {
String month = "no month";
int day = 0;
int year = 0;
switch(month) {
case "1":
month = "January";
break;
case "2":
month = "February";
break;
case "3":
month = "March";
break;
case "4":
month = "April";
break;
case "5":
month = "May";
break;
case "6":
month = "June";
break;
case "7":
month = "July";
break;
case "8":
month = "August";
break;
case "9":
month = "September";
break;
case "10":
month = "October";
break;
case "11":
month = "November";
break;
case "12":
month = "December";
break;
}
return arrivalDate1 = "Arrival Date: " + month + day + year;
return arrivalDate1;
}
}