public List<TextOption> getTimeTrackingFormats() { try { final BigDecimal hoursPerDay = new BigDecimal(getHoursPerDay()); final BigDecimal daysPerWeek = new BigDecimal(getDaysPerWeek()); final I18nHelper i18nBean = authenticationContext.getI18nHelper(); final String durationPretty = new JiraDurationUtils.PrettyDurationFormatter(hoursPerDay, daysPerWeek, i18nBean).format(SAMPLE_DURATION); final String durationDays = new JiraDurationUtils.DaysDurationFormatter(hoursPerDay, i18nBean).format(SAMPLE_DURATION); final String durationHours = new JiraDurationUtils.HoursDurationFormatter(i18nBean).format(SAMPLE_DURATION); return CollectionBuilder.newBuilder( new TextOption(JiraDurationUtils.FORMAT_PRETTY, getText(JiraDurationUtils.PrettyDurationFormatter.KEY_FORMAT_PRETTY, durationPretty)), new TextOption(JiraDurationUtils.FORMAT_DAYS, getText(JiraDurationUtils.DaysDurationFormatter.KEY_FORMAT_DAYS, durationDays)), new TextOption(JiraDurationUtils.FORMAT_HOURS, getText(JiraDurationUtils.HoursDurationFormatter.KEY_FORMAT_HOURS, durationHours))).asList(); } catch (NumberFormatException ignored) { } catch (ArithmeticException ignored) { } // can be caused by invalid input. It will be caught above in validation return Collections.emptyList(); }
private String format(final Long duration, final ResourceBundle resourceBundle) { 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 getDurationPrettySeconds(duration, resourceBundle, secondsPerDay, secondsPerWeek); }
public String format(Long duration) { return format(duration, locator.getHelper().getDefaultResourceBundle()); }
public String format(Long duration, Locale locale) { return format(duration, locator.getHelper(locale).getResourceBundle()); }
/** * Used by the Time Tracking report to show shorter durations than full pretty format. * * @return a duration String in the format "1d 3h 30m". */ public String shortFormat(Long duration) { return shortFormat(duration, Locale.UK); }
public SchedulerAdmin(SchedulerService schedulerService, SchedulerHistoryService schedulerHistoryService, PageBuilderService pageBuilderService, I18nHelper i18nHelper) { this.schedulerService = schedulerService; this.schedulerHistoryService = schedulerHistoryService; this.pageBuilderService = pageBuilderService; this.durationFormatter = new JiraDurationUtils.PrettyDurationFormatter(HOURS_PER_DAY, DAYS_PER_WEEK, i18nHelper); registeredJobRunners = schedulerService.getRegisteredJobRunnerKeys(); }