日期:2014-05-20 浏览次数:20791 次
import org.joda.time.DateTime; DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); DateTime begin = new DateTime(2011,8,11,13,00,00); DateTime end = new DateTime(2011,9,13,12,00,00); for(DateTime dt = begin;dt.isBefore(end);dt= dt.plusHours(1)){ System.out.println(formatter.format(dt.toDate())); }
------解决方案--------------------
[code=Java][/code]
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
GregorianCalendar begin = new GregorianCalendar(2011,8,11,13,00,00);
GregorianCalendar end = new GregorianCalendar(2011,9,13,12,00,00);
for(GregorianCalendar gc=begin; !gc.after(end); gc.add(Calendar.HOUR, 1))
System.out.println(sdf.format(gc.getTime()));
[code=Java][/code]