在我的程序中,我需要遍歷各種日期。我正在用java編寫這個程序,並且對讀者有一些經驗,但是我不知道哪個讀者會最好地完成這個任務,或者如果另一個班級會更好地工作。 的日期將被輸入到一個文本文件中的格式如下:如何從輸入文件創建變量
1/1/2013 to 1/7/2013
1/8/2013 to 1/15/2013
或者這樣的一些東西。我需要將每個日期範圍分解成6個循環的局部變量,然後將它們更改爲下一個循環。這些變量將被編碼,例如:
private static String startingMonth = "1";
private static String startingDay = "1";
private static String startingYear = "2013";
private static String endingMonth = "1";
private static String endingDay = "7";
private static String endingYear = "2013";
我想可以這樣做創建幾個分隔符查找,但我不知道,這將是最簡單的方法。我一直在尋找this的幫助,但似乎找不到相關答案。什麼是最好的方式去做這件事?
我建議你看看'SimpleDateFormat'類。也許你可以用'parse'方法做些什麼。 –