I want to parse a user input to a date with the following code:
public class AlterBerechnen {
public static String date;
public static void main(String[] args) {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Wann wurden sie geboren (DD.MM.YYYY) :");
SimpleDateFormat dateformat = new SimpleDateFormat("dd.MM.YYYY");
Date geb = null;
try {
try {
date = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
geb = dateformat.parse(date);
} catch (ParseException e) {
e.printStackTrace();
System.out.println("Hier ist eine fehlangabe erfolgt!!!!");
}
System.out.println(geb);
}}
But if I enter 17.12.1993 I get Mon Jan 04 00:00:00 CET 1993. Please help me, I read two hours in the internet, its the resolution I found, but it didn't work. Best regards Nils