ProjectActivity implements Serializable, Comparable<ProjectActivity> { public final double getDuration() { final long timeMilliSec = end.getMillis() - start.getMillis(); final double timeMin = timeMilliSec / 1000.0 / 60.0; return timeMin / 60.0; } ProjectActivity(final DateTime start, final DateTime end, final Project project);  ProjectActivity(final DateTime start, final DateTime end, final Project project,
            final String description); long getId(); void setId(long id); String getDescription(); void setDescription(final String description); void setDay(final DateTime day); DateTime getDay(); DateTime getEnd(); void setEndTime(final int hours, final int minutes); Project getProject(); void setProject(final Project project); DateTime getStart(); void setStartTime(final int hours, final int minutes); @Override String toString(); @Override int compareTo(final ProjectActivity activity); final double getDuration(); static final String PROPERTY_START; static final String PROPERTY_END; static final String PROPERTY_DATE; static final String PROPERTY_PROJECT; static final String PROPERTY_DESCRIPTION; }
@Test public void testCalculateDuration() { ProjectActivity act; DateTime startTime = new DateTime(DateUtils.getNow()); act = new ProjectActivity(startTime, startTime.plusMinutes(45), null); assertEquals(0.75, act.getDuration(), 0); act = new ProjectActivity(startTime, startTime.plusMinutes(30), null); assertEquals(0.5, act.getDuration(), 0); act = new ProjectActivity(startTime, startTime.plusHours(1).plusMinutes(30), null); assertEquals(1.5, act.getDuration(), 0); act = new ProjectActivity(startTime, startTime.plusMinutes(20), null); assertEquals(1.0/3, act.getDuration(), 0); }