Last active
October 31, 2016 14:37
-
-
Save facundofarias/8914939c72de6b7d47f2f23cbacf35d0 to your computer and use it in GitHub Desktop.
Split JodaTime Interval into intervals
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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