1

i'm newbie in Java ...i create this Class to calculate age from java.util.Date but compiler gave me error "cannot find symbol" for LocalDate instance variable ...may any one explain why and correct it ? [can not find symbol][1]

this is the code:
import java.util.Date;
public class TimeAndAge extends CheckDate 
{
private LocalDate birthDate;
private LocalDate now;
private LocalDate age;

public TimeAndAge (int theYear,int theMonth,int      
     theDay,LocalDatebirthdate,LocalDate now,Years age)             
   {
    super(theYear,theMonth,theDay);
    this.birthDate = birthDate;
    this.now = now;
    this.age=age;
}


 public void setBirthDate(LocalDate birthdate)   
 {
    birthdate = new    
   LocalDate(super.getYear(),super.getMonth(),super.getDay());
  }
 public LocalDate getBirthDate()
  {
   return birthDate;
  }
  public void setNow(LocalDate now)
  {
    now = new LocalDate();
  }
  public LocalDate getNow()
  {
    return now;
   }
   public void setAge(Years age)    
  {
    age = Years.yearsBetween(birthdate, now);
  } 
  public Years getAge()
    {
    return age;
   }        
  }
  • 1
    Add `import java.time.LocalTime;` to you class, just below the `package` declaration and above the `class` declaration - have a look at [Using Package Members](https://docs.oracle.com/javase/tutorial/java/package/usepkgs.html) for more details – MadProgrammer Oct 29 '15 at 23:57
  • Don't post code as image but simply copy and paste it into your question so we could copy-paste it into our computers and reproduce your error. – Pshemo Oct 29 '15 at 23:57
  • Show us your class please. – Mark Sholund Oct 29 '15 at 23:58
  • which version of Java are you using? (please use java 8 or more). if you have java8 use this import java.time.LocalDate; – RamPrakash Oct 30 '15 at 00:52

0 Answers0