我已經導入了joda libary,並且能夠導入Easy Reader類。不過,我需要幫助格式正確,所以我可以計算在這之間的日子,是的,我與MM/dd/yyyy一起,但我使用了整數。我需要導入其他東西嗎?我對喬達真的很陌生,所以請耐心等待,謝謝。一切似乎工作正常,但我找不到正確的語法,這將幫助我找到兩個日期之間的差異,我找不到它。宣佈開始日期和結束使用喬達時間?
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!");
}
}
僅供參考,[Joda-Time](http://www.joda.org/joda-time/)項目現在處於[維護模式](https:/ /en.wikipedia.org/wiki/Maintenance_mode),團隊建議遷移到[java.time](http://docs.oracle.com/javase/8/docs/api/java/time/package-summary .html)類。請參見[Oracle教程](https://docs.oracle.com/javase/tutorial/datetime/TOC.html)。 –