I am interested in any library which can do the following:
I have a time range: let's say 1995 to 2010 which I can classify in some way, let's say as "The Internet Era".
I then want to be able to break that up further, say 2001-2010 as "The Google Era".Ideally, I'd like the time line to exist as some sort of list of timespans objects (or an object with a start and end date), one for each era. So after these two add operations, it would look like:
1995-2000 - The Internet Era (the end date is truncated so as to not overlap)
2001-2开发者_StackOverflow中文版010 - The Google Era
A simple set "Event" of objects with a start & end time (Using Joda perhaps?) and description should be a good start.
Drop them into a Timeline container that sorts them by start time, then running through the events should give you the data you want in any manner you require.
Sometimes solutions are so straight-forward that writing a generic library for them will actually detract from your solution--it would just mask your storage structure, stick you with a non-optimal format and not really hide much code at all.
i suggest you look at the joda-time library, specifically Duration and Interval classes
I would say (as usually ) Joda Time, you should look inside their key concepts onto the web-page to see if one or a combination of more is suitable for your needs.
精彩评论