Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: "cannot find symbol-method" error

  1. #1
    Junior Member
    Join Date
    Aug 2018
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default "cannot find symbol-method" error

    Hello,

    I am struggling using the method between(LocalDate startDateInclusive, LocalDate endDateExclusive) from java.time.Period. It keeps highlighting "between" and gives me the syntax error "cannot find symbol-method between(LocalDate startDateInclusive, LocalDate endDateExclusive)".
    import java.time.LocalDate;
    import java.time.Period;
     
    public class test
    {
        private LocalDate birthdate;
     
        public test(LocalDate day)
        {
            birthdate = day;
        }
        public int getAge()
        {
            Period time = between(LocalDate.now(),birthdate);
            int age = time.getYears();
            return age;
        }  
    }

    I hope somebody can help me implement this method correctly.
    Thanks in advance
    Raf
    Last edited by raf sevenants; August 26th, 2018 at 07:54 AM. Reason: solved

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: "cannot find symbol-method" error

    "cannot find symbol-method between(LocalDate startDateInclusive, LocalDate endDateExclusive)".
    The compiler can not find a method named: between that takes the arguments shown in the error message.

    Where is that method defined? What class is it in?

    Can you copy the API doc for the method and paste it here?
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Aug 2018
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: "cannot find symbol-method" error


  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: "cannot find symbol-method" error

    Ok, thanks.
    The between method is defined as static. That means to call it you need to use the name of the class with the method:
      Period.between(<args here>)

    See: https://docs.oracle.com/javase/tutor...classvars.html
    If you don't understand my answer, don't ignore it, ask a question.

  5. The Following User Says Thank You to Norm For This Useful Post:

    raf sevenants (August 25th, 2018)

  6. #5
    Junior Member
    Join Date
    Aug 2018
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: "cannot find symbol-method" error

    thank you very much, this mistake would have saved me redoing the exam

Similar Threads

  1. "cannot find symbol" error
    By fazil in forum What's Wrong With My Code?
    Replies: 3
    Last Post: July 5th, 2014, 04:23 AM
  2. "Error cannot find symbol" "throws BadLocationException"
    By coltson in forum AWT / Java Swing
    Replies: 1
    Last Post: June 30th, 2013, 10:33 PM
  3. "cannot find symbol" error when trying to use the getInt() method.
    By simpson_121919 in forum Collections and Generics
    Replies: 6
    Last Post: February 21st, 2013, 12:48 PM
  4. Replies: 3
    Last Post: January 22nd, 2013, 07:14 AM
  5. "Cannot find symbol" compilation error
    By collegejavastudent in forum What's Wrong With My Code?
    Replies: 7
    Last Post: December 12th, 2011, 05:07 PM