用joda-time替代难用的java日期时间类型
- 增加/减少天数可以用plusDays,minusDays,避免了用一天的秒数86400来乘天数。
- 输出字符串可以用toString,避免一堆类似:SimpleDateFormat sdf = new SimpleDateFormat(“yyyy”);
- 还有更多的方便的请自行搜索joda-time吧。
DateTime tDay=new DateTime(TNU.queryITETime().getEpochSecond()*1000).minusDays(Integer.parseInt(Newoffset));
for (int k=0; k<innerDays; k++){
doDay = tDay.plusDays(k);
tFilterPath = REMOTE_PATH.replaceAll("(?i)<yyyy>",doDay.toString("yyyy"));
......
pom.xml只需要:
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.10.3</version>
</dependency>