I'm having a hard time with a few things. I'm fairly new to Java and I can't figure out how to read the first two digits to determine 08 or 09 due to the Octal digits. Also I'm getting a return of null, 1, 199 which don't need to be there. Help would be appreciated.
import java.util.*;
public class Dates {
public static void main(String[] args) {
String January,February, March, April, May, June, July,
August, September,October, November, December, month;
January = February = March = April = May = June = July =
August = September = October = November = December = month = null;
Scanner myScanner = new Scanner(System.in);
System.out.print("Enter date in the format mm/dd/yyyy: ");
String input = myScanner.next();
String months = input.substring(0,1);
int monthInt = Integer.parseInt(months);
if (monthInt == 01){
month = January;
}
else if (monthInt == 02){
month = February;
}
else if (monthInt == 03){
month = March;
}
else if (monthInt == 04){
month = April;
}
else if (monthInt == 05){
month = May;
}
else if (monthInt == 06){
month = June;
}
else if (monthInt == 07){
month = July;
}
else if (monthDouble == 08){
month = August;
}
else if (monthDouble == 09){
month = September;
}
else if (monthInt == 10){
month = October;
}
else if (monthInt == 11){
month = November;
}
else if (monthInt == 12){
month = December;
}
else {
System.out.println("Invalid Month");
}
String days = input.substring(3,4);
int daysInt = Integer.parseInt(days);
if ((daysInt <= 31) && (monthInt == 1 || monthInt == 3 || monthInt ==
5 || monthInt == 7 || monthInt == 8 || monthInt == 10 || monthInt
== 12)){
daysInt = daysInt;
}
else if ((daysInt <= 30) && (monthInt == 4 || monthInt == 6 || monthInt
== 9 || monthInt == 11)){
daysInt = daysInt;
}
else if ((daysInt <= 28) && (monthInt == 2)){
daysInt = daysInt;
}
else
System.out.println("Invalid Day");
String year = input.substring(6,9);
int yearInt = Integer.parseInt(year);
if (yearInt >= 1900 && yearInt <= 2014) {
yearInt = yearInt;
}
else {
System.out.println("Year should be between 1900 and 2014");
}
String checkSlash = input.substring(2);
char slash = checkSlash.charAt(0);
if (slash == '/')
slash = slash;
else
System.out.println("Invalid format. Use mm/dd/yyyy");
System.out.println(month + " " + daysInt + ", " + year);
}
}