Source Code : Compare Dates
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
Compare Dates
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class CompareDates {
public static void main(String[] args) throws ParseException {
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
// Get Date 1
Date d1 = df.parse("2000-02-01");
// Get Date 2
Date d2 = df.parse("2001-03-02");
String relation;
if (d1.equals(d2))
relation = "the same date as";
else if (d1.before(d2))
relation = "before";
else
relation = "after";
System.out.println(d1 + " is " + relation + + d2);
}
}
Thank with us