I am having some difficulty understanding the way to change a user input of dates an an int to be compared to another int. Am trying to get the user to input his date of birth, then compare it to zodiac signs dates in a switch format if it is possible. Going through most of the post on how to change an input to int, with pars, and SimpleDateFormat I was not able to apply it, as shown in my code when I try to implement "dateOB" that should've been formated to an int, in the switch statement it did not recognize it as so ...
My code so far:
import java.util.*;
import java.text.*;
public class signs {
public static void main(String[] args) {
Scanner userInput = new Scanner (System.in);
// Intro message
System.out.println("Hello you, Lets get to know each other");
// User input begin
//name
String userName;
System.out.println("What is your name ?");
userName = userInput.nextLine();
//date of birth
System.out.println(userName + " please enter you DoB (DD/MM/YYY)");
String dateOB = userInput.next();
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/mm/yyyy");
try {
Date date = new SimpleDateFormat("dd/MM/yyyy").parse(dateOB);
System.out.println(dateOB);
} catch (ParseException e) {
e.printStackTrace();
return;
}
System.out.println("So your date of birth is " + dateOB);
// choosing zodiac sign
//starting the switch statement
int convertedDate = dateOB;
String zodiacSign;
switch (convertedDate){
}
}
}
I would appreciate it if someone could explain to me how to implement this in a simple way ...
So i get really great suggestion by you guys, and i ended up with the right understanding of things, just complication implementing minor suggestion to make the code function the right way,
what i got so far is :
boolean correctFormat = false;
do{
System.out.println(userName + " please enter you DoB (DD/MM/YYY)");
String dateOB = userInput.next();
try{
Date date = new SimpleDateFormat("dd/MM/yyyy").parse(dateOB);
System.out.println(dateOB);
System.out.println("So your date of birth is " + dateOB);
correctFormat = true;
}catch(ParseException e){
correctFormat = false;
}
}while(!correctFormat);
So the problem i am facing is that " dateOB is now since it is inside a while loop, is not recognized out side the loop, which is checking if the date format is right , so when i try and conver the date to a number : int dayNmonth = Integer.parseInt(new SimpleDateFormat("ddMM").format(dateOB));
Calendar cal = Calendar.getInstance();
cal.setTime(date);
int day = cal.get(Calendar.DAY_OF_MONTH);
//int month = cal.get(Calendar.MONTH)+ 1;
it is not accepted ?
how do i tackle this issue ?

Hey so far i've been having some trouble with part of the code:
Calendar cal = Calendar.getInstance();
cal.setTime(dayNmonth);
int day = cal.get(Calendar.DAY_OF_MONTH);
int month = cal.get(Calendar.MONTH)+ 1;
as in eclips it wont let me get the day and the month from "dateOB" with this code.

could someone try and help me understand what is the problem !?

int date = Integer.parseInt(dateOB.substring(0,2)),int month = Integer.parseInt(dateOB.substring(2,4))and so far. And then you can compare it with another int date value.