如何将java.util.Calendar转换为org.quartz.impl.calendar.DailyCalendar?

时间:2015-10-29 14:43:29

标签: java calendar quartz-scheduler

我有两个不同的日历。我需要在OptionOption之间进行转换。这样做的最佳方法是什么?

也许Quartz库中有一些转换器?

1 个答案:

答案 0 :(得分:0)

You may need to have two java.util.Calendars for each DailyCalendar, one that is set to the start time, and one that is set to the end time.

Converting from two java.util.Calendar objects to one DailyCalendar object:

java.util.Calendar start = Calendar.getInstance();
start.setTimeInMillis(System.currentTimeMillis() - 360000); // an hour ago

java.util.Calendar end = Calendar.getInstance();
end.setTimeInMillis(System.currentTimeMillis()); // now

DailyCalendar dc = new DailyCalendar(start.getTimeInMillis(), end.getTimeInMillis());

Converting back:

start.setTimeInMillis(dc.getTimeRangeStartingTimeInMillis());
end.setTimeInMillis(getTimeRangeEndingTimeInMillis());