public LPServiceTimer addServiceTimer(LPServiceTimer newTime, long userId) throws SystemException, PortalException { LPServiceTimer timer = lpServiceTimerPersistence.create( counterLocalService.increment(LPServiceTimer.class.getName())); timer.setBillId(newTime.getBillId()); timer.setClientId(newTime.getClientId()); timer.setMatterId(newTime.getMatterId()); timer.setStartTime(newTime.getStartTime()); timer.setStopTime(newTime.getStopTime()); Date startTime = newTime.getStartTime(); Date stopTime = newTime.getStopTime(); timer.setHourSpent(startTime.getTime() - stopTime.getTime()); timer.setCreateDate(new Date()); resourceLocalService.addResources( newTime.getBillId(), newTime.getClientId(), userId, LPServiceTimer.class.getName(), timer.getPrimaryKey(), false, true, true); return lpServiceTimerPersistence.update(timer, false); }