0
雖然提到我碰到下面的代碼來獲取當天某一課程:儒略日VS Date對象得到了本日
int julianStartDay = Time.getJulianDay(System.currentTimeMillis(), dayTime.gmtoff);
long dateTime;
dateTime = dayTime.setJulianDay(julianStartDay);
day = getReadableDateString(dateTime);
private String getReadableDateString(long time){
SimpleDateFormat shortenedDateFormat = new SimpleDateFormat("E MMM d");
return shortenedDateFormat.format(time);
}
我的疑問是,爲什麼我們使用這個朱利安方法來代替只是直接從Date類對象中提取當天的日期和時間。
兩個問題:1.你問爲什麼你的例子使用'getJulianDay()'而不是直接使用'System.currentTimeMilis()'?和2.這個特殊的例子有多大? – ricky3350
1.是的,也無法直接使用Date類對象來獲取當前日期? 2.關於故鄉,我不知道,但我猜它在2012年之後...... – ghostrider
上面的代碼似乎做了兩件事:(1)將變量dayTime的值更改爲今天午夜,原始時區,以及(2)將'day'設置爲表示今天的字符串。你如何打算用'Date'做第一部分? – RealSkeptic