我已经导入了joda库,我可以导入Easy Reader类。但是,我需要帮助格式化正确,所以我可以计算两者之间的日期,是的,我有MM / dd / yyyy,但我使用了整数。我还需要进口其他东西吗?我是joda的新手,所以请耐心等待,谢谢。一切似乎工作正常,但我找不到正确的语法,这将帮助我找到两个日期之间的差异,我找不到它。
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!");
}
}
答案 0 :(得分:0)
此
int Days;
Days.daysBetween(new LocalDate(start),new LocalDate(end)).getDays();
应该是
int dayCount = Days.daysBetween(start, end).getDays();
由于start
和end
已经LocalDate
(s),并且您希望保存通话结果。此外,您只需要一个 EasyReader
实例。而且,您需要添加
import org.joda.time.Days;