//Program to calculate number of days between 2 dates
import java.util.Date;
import java.text.SimpleDateFormat;
class Example
{
public static void main(String args[])
{
SimpleDateFormat myFormat = new SimpleDateFormat("dd MM yyyy");
String d1 = "01 01 2018";
String d2 = "22 02 2019";
try {
Date dateBefore = myFormat.parse(dateBeforeString);
Date dateAfter = myFormat.parse(dateAfterString);
long difference = dateAfter.getTime() - dateBefore.getTime();
float daysBetween = (difference / (1000*60*60*24));
System.out.println("Number of Days between dates: "+daysBetween);
}
catch (IOException e)
{
System.out.println("Invalid");
}
}
}