class TimeSpan implements Comparable<TimeSpan>, Serializable, TimeSpanProvider, SizeProvider {

    public List<TimeSpan> subDivide(int divisions)
    {
        if (divisions <= 1)
        {
            throw new IllegalArgumentException("divisions must be greater than 1");
        }
        if (!isBounded())
        {
            throw new IllegalStateException("Indefinite time spans cannot be subdivided.");
        }

        double binSizeMs = (double)getDurationMs() / (double)divisions;
        if (binSizeMs < 1.0)
        {
            throw new IllegalArgumentException("Resultant number of subdivisions results in sub span sizes of less than 1 ms");
        }

        long binWidth = (int)Math.round(binSizeMs);
        TimeSpan[] bins = new TimeSpan[divisions];
        long curStart = getStart();
        long curEnd = curStart + binWidth;
        for (int count = 0; count < divisions; count++)
        {
            bins[count] = TimeSpan.get(curStart, curEnd);
            curStart = curEnd;
            if (count < divisions - 2)
            {
                curEnd = curEnd + binWidth;
            }
            else
            {
                curEnd = getEnd();
            }
        }
        return Arrays.asList(bins);
    }

}