-1

I've already imported the joda libary and I was able to import the Easy Reader class. However, I need help formatting correctly so I can calculate the days in between, and yes, I am aquainted with the MM/dd/yyyy, but I've used integers. Do I need to import anything else? I'm really new at joda, so please be patient, thanks. Everything seems to work fine, but I cant find the right syntax that will help me find the difference between the two dates, and I can't find it.

import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.LocalDate;
class starter{
public static void BdayPrgm(String args[]){

System.out.println("Please Enter Today's Month: ");
        EasyReader month = new EasyReader();
        //this will indentify it as an INT, not a string.
        //quest is a question btw.
        todaysmon = month.readInt();

        System.out.println("What number is today?: ");
        EasyReader currentday = new EasyReader();
        todayday = currentday.readInt();



        System.out.println("What is today's year?: ");
        EasyReader todayyear = new EasyReader();
        year = todayyear.readInt();

        System.out.println("");

        System.out.println("What is your BdayMonth?: ");
        EasyReader thatyear = new EasyReader();
        bdaymon = thatyear.readInt();

        System.out.println("What is your Bday #?: ");
        EasyReader thatday = new EasyReader();
        thatgr8day = thatday.readInt();

        System.out.println("What is the bdayyear?: ");
        EasyReader bdayyear = new EasyReader();
        bdayyr = bdayyear.readInt();


        int age;
        age = year - bdayyr;


        //we can get start date by putting test maybe?
        DateTimeZone LA = DateTimeZone.forID("America/Los_Angeles");
        LocalDate start = new LocalDate(year,todaysmon,todayday);
        LocalDate end = new LocalDate(year,bdaymon,thatgr8day);

        int Days;
        //code isn't compileing below. I don't know what I'm doing wrong.
        Days.daysBetween(new LocalDate(start),new LocalDate(end)).getDays();

        //int days = d.getdays;

        System.out.println("");

        System.out.println(CELEB1+" is going to be "+age+" years old in X days!");

}

}
  • 1
    FYI, the [Joda-Time](http://www.joda.org/joda-time/) project is now in [maintenance mode](https://en.wikipedia.org/wiki/Maintenance_mode), with the team advising migration to the [java.time](http://docs.oracle.com/javase/8/docs/api/java/time/package-summary.html) classes. See [Tutorial by Oracle](https://docs.oracle.com/javase/tutorial/datetime/TOC.html). – Basil Bourque Aug 22 '17 at 04:11

1 Answers1

0

This

int Days;
Days.daysBetween(new LocalDate(start),new LocalDate(end)).getDays();

should be something like

int dayCount = Days.daysBetween(start, end).getDays();

Because start and end are already LocalDate(s) and you want to save the result of the call. Also, you should only need one EasyReader instance. And, you'll need to add

import org.joda.time.Days;
Elliott Frisch
  • 198,278
  • 20
  • 158
  • 249
  • C:\Users\owner\Desktop\BdayAssignment>javac *.java starter.java:81: error: cannot find symbol int dayCount = Days.daysBetween(start, end).getDays(); ^ symbol: variable Days location: class starter 1 error C:\Users\owner\Desktop\BdayAssignment>pause Press any key to continue . . . It still isn't hasn't compiled. I'm trying to find the right parameters, but it's wrong... – Moses Apostol Aug 22 '17 at 02:44
  • @PYRO912 `import org.joda.time.Days;` – Elliott Frisch Aug 22 '17 at 02:45
  • It works. Thanks. forgot to add the import – Moses Apostol Aug 22 '17 at 02:49