Problem with dates

ok i have a problem with a method to get the year from 2 date objects and compare them. can someone tell me where im going wrong.

publicboolean yearSame()

{

int yearSold = dateSold.get(Calendar.YEAR);

int yearBuilt = dateBuilt.get(Calendar.YEAR);

if(yearSold == yearBuilt)

{

returntrue;

}else{

returnfalse;

}

}

this the method and im gettin an error of cannot find symbol - method get(int)

here is the constructor and instance variables of this class

publicclass Houseimplements Serializable

{

// instance variables - replace the example below with your own

private String houseId;

private String address;

private Date dateBuilt;

privatedouble sellingPrice;

privateboolean isSold;

private Date dateSold;

private Buyer buyer;

/**

* Constructor for objects of class House

*/

public House(String houseId,String address,double sellingPrice,int yearBuilt,int monthBuilt,int dayBuilt )

{

this.houseId = houseId;

this.address = address;

this.sellingPrice = sellingPrice;

isSold =false;

Calendar cal =new GregorianCalendar( yearBuilt, monthBuilt - 1 ,dayBuilt);

dateBuilt = cal.getTime();

}

[2570 byte] By [mollemana] at [2007-11-27 3:40:43]
# 1
Looks like dateSold and dateBuilt are Date instances.There is in fact no get(int) method in the Date class.I guess you have the Calendar's get(int) method in mind.(If it's the case, you know what to do, right ?)
TimTheEnchantora at 2007-7-12 8:44:11 > top of Java-index,Java Essentials,New To Java...
# 2
use getYear() method ex.year = dateObj.getYear();get(Calendar.YEAR) is for calendar not for date,sudhir http://www.jyog.com
Sudhir_nimavata at 2007-7-12 8:44:11 > top of Java-index,Java Essentials,New To Java...