how to enter parameter (date1 or date2) in mani() method of java.
my code compilies but i didnt allow me enter value of dates to compare
the
main class Date work according my expectation and test Date is to compare dates
cade is:
public class TestDate
{
// instance variables - replace the example below with your own
private Date date1;
private Date date2;
/**
* Constructor for objects of class TestDate
*/
public TestDate(Date date1, Date date2)
{
// initialise instance variables
this. date1 = date1;
this.date2 = date2;
}
public static void main(String[] args)
{
Date date1 = new Date();
date1.setDate(date1.getMonth(), date1.getDay(), date1.getYear());
Date date2 = new Date();
date2.setDate(date2.getMonth(), date2.getDay(), date2.getYear());
date1.isEqual(date2);
if (date1 == date2)
{
System.out.println(date1 + "is equals to" + date2);
}
else
{
//do nothing
}
boolean early = date1.isEarlier(date2);
if(early)
{
System.out.println(date1 + "greater than" + date2);
}
else
{
// do nothing
}
boolean later = date1.isLater(date2);
{
if(later)
{
System.out.println(date1 + "later than" + date2);
}
else
{
// do nothing
}
}
}
}
Tags: