If you know where are your month, year and day like : 25/10/2020
you can just use the split function
If you are SURE that the date will be in the right format :
String[] dateSplit = date.split("/");
int day = Integer.valueOf(dateSplit[0]);
int month = Integer.valueOf(dateSplit[1]);
int year = Integer.valueOf(dateSplit[2]);
System.out.println("year" + year);
System.out.println("month" + month);
System.out.println("day" + day);
If you are NOT SURE that the date will be in the right format :
String[] dateSplit = date.split("/");
if (dateSplit.length != 3) {
throw new Exception("Date not in valid format");
//or do something else like printing or whatever...
}
try {
int day = Integer.valueOf(dateSplit[0]);
int month = Integer.valueOf(dateSplit[1]);
int year = Integer.valueOf(dateSplit[2]);
System.out.println("year" + year);
System.out.println("month" + month);
System.out.println("day" + day);
} catch (NumberFormatException e) {
throw new Exception("Date not in valid format");
//or do something else like printing or whatever...
}