我有一個文檔,從日期X開始,在日期Y結束,並且上升一天。我的任務是查看這個文檔,找出文檔中缺少多少天。在java中使用日曆或Joda-Time
Example:
19990904 56.00
19990905 57.00
19990907 60.00
需要打印出19900906缺失。
我已經做了一些研究並閱讀了有關Java日曆,日期和Joda-Time的內容,但無法理解它們中的任何一個。有人可以解釋一下我剛纔提到的這些功能嗎,然後就如何使用它來實現我的目標提出建議?
我已經有這樣的代碼:
String name = getFileName();
BufferedReader reader = new BufferedReader(new FileReader(name));
String line;
while ((line = reader.readLine()) != null)
{ //while
String delims = "[ ]+";
String [] holder = line.split(delims);
// System.out.println("*");
int date = Integer.parseInt(holder[0]);
//System.out.println(holder[0]);
double price = Double.parseDouble(holder[1]);
我需要導入任何東西才能使用JodaTime嗎? – Danny
@Danny yeah jodatime本身http://mvnrepository.com/artifact/joda-time/joda-time/2.2 – NimChimpsky
我因爲使用LocalDate和DateTimeFormatter – Danny