Skip to content

Instantly share code, notes, and snippets.

Last active October 31, 2016 14:37
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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