//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");
}
}
}
Thank you sir...i am arunabha pal of 8b thank u for doing the given programe thanks for the help before exam.
ReplyDelete'programme' spelling wrong.
DeleteThanks Sir for the post
ReplyDeleteAll clear before exams!
Sir I am Swagata Ganguly Of Class VIII C .
ReplyDeleteI cant understand what to do in prog.9 .
Sir i am debadree Sekhar das of class VIII C ....I am having problem to do program 10
ReplyDelete