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