public static String getDurationString(long l, int hoursPerDay, int daysPerWeek) { long secondsInDay = hoursPerDay * Duration.HOUR.getSeconds(); long secondsPerWeek = daysPerWeek * secondsInDay; return getDurationStringSeconds(l, secondsInDay, secondsPerWeek); }
/** * Get a duration string representing the given number of seconds. The string will use the largest unit possible. * (i.e. 1w 3d) * * @param l the number of seconds * @param hoursPerDay hours in a working day * @param daysPerWeek days in a working week * @return the duration string */ public static String getDurationString(long l, int hoursPerDay, int daysPerWeek) { long secondsInDay = hoursPerDay * Duration.HOUR.getSeconds(); long secondsPerWeek = daysPerWeek * secondsInDay; return getDurationStringSeconds(l, secondsInDay, secondsPerWeek); }
public String shortFormat(final Long duration, final Locale locale) { final BigDecimal secondsPerHour = BigDecimal.valueOf(DateUtils.Duration.HOUR.getSeconds()); final long secondsPerDay = hoursPerDay.multiply(secondsPerHour).longValueExact(); final long secondsPerWeek = daysPerWeek.multiply(hoursPerDay).multiply(secondsPerHour).longValueExact(); return DateUtils.getDurationStringSeconds(duration, secondsPerDay, secondsPerWeek); }
/** * Get String representation of a duration * <p/> * * @param seconds Number of seconds * @return String representing duration, eg: "1h 30m" * @see #getDurationStringWithNegative(long) */ public static String getDurationString(long seconds) { return getDurationStringSeconds(seconds, Duration.DAY.getSeconds(), Duration.WEEK.getSeconds()); }
/** * Get String representation of a duration * <p/> * * @param seconds Number of seconds * @return String representing duration, eg: "1h 30m" * @see #getDurationStringWithNegative(long) */ public static String getDurationString(long seconds) { return getDurationStringSeconds(seconds, Duration.DAY.getSeconds(), Duration.WEEK.getSeconds()); }
private String getTimeLoggedString(long timeSpent) { final BigDecimal hoursPerDay = timeTrackingConfiguration.getHoursPerDay(); final BigDecimal daysPerWeek = timeTrackingConfiguration.getDaysPerWeek(); final BigDecimal secondsPerHour = BigDecimal.valueOf(DateUtils.Duration.HOUR.getSeconds()); final long secondsPerDay = hoursPerDay.multiply(secondsPerHour).longValueExact(); final long secondsPerWeek = daysPerWeek.multiply(hoursPerDay).multiply(secondsPerHour).longValueExact(); return DateUtils.getDurationStringSeconds(timeSpent, secondsPerDay, secondsPerWeek); } }
private static String getTimeLoggedString(long timeSpent) { final BigDecimal hoursPerDay = getTimeTrackingConfiguration().getHoursPerDay(); final BigDecimal daysPerWeek = getTimeTrackingConfiguration().getDaysPerWeek(); final BigDecimal secondsPerHour = BigDecimal.valueOf(DateUtils.Duration.HOUR.getSeconds()); final long secondsPerDay = hoursPerDay.multiply(secondsPerHour).longValueExact(); final long secondsPerWeek = daysPerWeek.multiply(hoursPerDay).multiply(secondsPerHour).longValueExact(); return DateUtils.getDurationStringSeconds(timeSpent, secondsPerDay, secondsPerWeek); }
public String doDefault() throws Exception { // Retrieve the worklog worklog = worklogService.getById(getJiraServiceContext(), getWorklogId()); if (worklog == null) { addErrorMessage(getText("logwork.error.update.invalid.id", (getWorklogId() == null) ? null : getWorklogId().toString())); return ERROR; } if (!worklogService.hasPermissionToUpdate(getJiraServiceContext(), worklog)) { //user doesn't have permission to run this action return "securitybreach"; } //pre-populate the fields final BigDecimal hoursPerDay = getHoursPerDay(); final BigDecimal daysPerWeek = getDaysPerWeek(); final BigDecimal secondsPerHour = BigDecimal.valueOf(DateUtils.Duration.HOUR.getSeconds()); final long secondsPerDay = hoursPerDay.multiply(secondsPerHour).longValueExact(); final long secondsPerWeek = daysPerWeek.multiply(hoursPerDay).multiply(secondsPerHour).longValueExact(); setTimeLogged(DateUtils.getDurationStringSeconds(worklog.getTimeSpent(), secondsPerDay, secondsPerWeek)); setStartDate(getFormattedStartDate(worklog.getStartDate())); setComment(worklog.getComment()); setCommentLevel(CommentVisibility.getCommentLevelFromLevels(worklog.getGroupLevel(), worklog.getRoleLevelId())); return super.doDefault(); }