1

I am developing (time scheduler) application in java. i have list of objects, which contains start and end time in form of long. what is the best way to find out remain time other then in my list of object. so i can display free time in particular day.

my object Structure,

List &ltTimeObj>
    |-------Long startTime,
    |-------Long endTime,

Output

List of free time like 00:00 to 08:00, 10:00 to 11:00 (i can do conversion of time my self)

1 Answers1

2

It's hard to parse your question. The one I'm answering is:

Given this timeline:

<---->     <-->     <------->  <>

Create this timeline ("remain time"):

      <--->    <-->          <>

My solution: stick with longs, don't convert to dates. Sort the list of TimeObjs and create a new list of TimeObjs, where each new TimeObj is constructed from the endTime of one TimeObj to the startTime of the next TimeObj, so long as startTime > endTime. That will give you a list of "remain time".

Paul Hicks
  • 13,289
  • 5
  • 51
  • 78