import java.util.*; public class Interval { private Date startDate_; // unique private Date endDate_; // unique public Interval() { startDate_ = new Date(); endDate_ = new Date(); } public synchronized void setStart(int date){ startDate_.setTime(date); } public synchronized void setEnd(int date){ endDate_.setTime(date); } public synchronized long duration() { return endDate_.getTime() - startDate_.getTime(); } } // class date // getTime // public long getTime() // Returns: // the number of milliseconds since January 1, // 1970, 00:00:00 GMT represented by this date.