Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Split JodaTime Interval into intervals
private static Collection<Interval> splitDuration(Interval interval, int chunks)
long startMillis = interval.getStartMillis();
long endMillis = interval.getEndMillis();
long durationMillis = endMillis - startMillis;
long chunkSize = durationMillis / chunks;
Collection<Interval> list = new ArrayList<Interval>();
for (int i = 1; i <= chunks; ++i) {
list.add(new Interval(startMillis, startMillis += chunkSize));
return list;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment