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 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); }
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); } }
/** * Converts a number of seconds into a pretty formatted data string. The resolution is in minutes. So if the number of seconds is greater than a minute, it will * only be shown down top minute resolution. If the number of seconds is less than a minute it will be shown in seconds. * <p/> * So for example <code>76</code> becomes <code>'1 minute'</code>, while <code>42</code> becomes <code>'42 seconds'</code> * * @param numSecs the number of seconds in the duration * @param hoursPerDay the hours in a day * @param daysPerWeek the number of days in a week * @param resourceBundle a resouce bundle for i18n * @return a string in readable pretty duration format, using minute resolution */ public static String getDurationPretty(long numSecs, int hoursPerDay, int daysPerWeek, ResourceBundle resourceBundle) { long secondsInDay = hoursPerDay * Duration.HOUR.getSeconds(); long secondsPerWeek = daysPerWeek * secondsInDay; return getDurationPrettySeconds(numSecs, secondsInDay, secondsPerWeek, resourceBundle, false); }
/** * This function retrieves a duration in seconds that depends on number of hours in a day and * days in a week * * @param durationStr to convert to a duration * @param hoursPerDay Number of hourse i day * @param daysPerWeek Days Per Week * @param defaultUnit the unit used when one is not specified on a measure in the durationStr * @return the duration in seconds * @throws InvalidDurationException if its badly formatted duration */ public static long getDuration(String durationStr, int hoursPerDay, int daysPerWeek, final Duration defaultUnit) throws InvalidDurationException { long secondsInDay = hoursPerDay * Duration.HOUR.getSeconds(); long secondsPerWeek = daysPerWeek * secondsInDay; return getDurationSeconds(durationStr, secondsInDay, secondsPerWeek, defaultUnit); }
/** * Converts a number of seconds into a pretty formatted data string. The resolution is in seconds. * <p/> * So for example <code>76</code> becomes <code>'1 minute, 16 seconds'</code>, while <code>42</code> becomes <code>'42 seconds'</code> * * @param numSecs the number of seconds in the duration * @param hoursPerDay the hours in a day * @param daysPerWeek the number of days in a week * @param resourceBundle a resouce bundle for i18n * @return a string in readable pretty duration format, using second resolution */ public static String getDurationPrettySecondsResolution(long numSecs, int hoursPerDay, int daysPerWeek, ResourceBundle resourceBundle) { long secondsInDay = hoursPerDay * Duration.HOUR.getSeconds(); long secondsPerWeek = daysPerWeek * secondsInDay; return getDurationPrettySeconds(numSecs, secondsInDay, secondsPerWeek, resourceBundle, true); }
/** * Converts a number of seconds into a pretty formatted data string. The resolution is in minutes. So if the number of seconds is greater than a minute, it will * only be shown down top minute resolution. If the number of seconds is less than a minute it will be shown in seconds. * <p/> * So for example <code>76</code> becomes <code>'1 minute'</code>, while <code>42</code> becomes <code>'42 seconds'</code> * * @param numSecs the number of seconds in the duration * @param resourceBundle a resouce bundle for i18n * @return a string in readable pretty duration format, using minute resolution */ public static String getDurationPretty(long numSecs, ResourceBundle resourceBundle) { return getDurationPrettySeconds(numSecs, Duration.DAY.getSeconds(), Duration.WEEK.getSeconds(), resourceBundle, false); }
public long getMilliseconds() { return 1000L * getSeconds(); }
/** * 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); }
/** * Converts a number of seconds into a pretty formatted data string. The resolution is in seconds. * <p/> * So for example <code>76</code> becomes <code>'1 minute, 16 seconds'</code>, while <code>42</code> becomes <code>'42 seconds'</code> * * @param numSecs the number of seconds in the duration * @param hoursPerDay the hours in a day * @param daysPerWeek the number of days in a week * @param resourceBundle a resouce bundle for i18n * @return a string in readable pretty duration format, using second resolution */ public static String getDurationPrettySecondsResolution(long numSecs, int hoursPerDay, int daysPerWeek, ResourceBundle resourceBundle) { long secondsInDay = hoursPerDay * Duration.HOUR.getSeconds(); long secondsPerWeek = daysPerWeek * secondsInDay; return getDurationPrettySeconds(numSecs, secondsInDay, secondsPerWeek, resourceBundle, true); }
private static String getDurationPrettySeconds(long numSecs, long secondsPerDay, long secondsPerWeek, ResourceBundle resourceBundle, boolean secondsDuration) { return getDurationPrettySeconds(numSecs, Duration.YEAR.getSeconds(), secondsPerDay, secondsPerWeek, resourceBundle, secondsDuration); }
/** * Converts a number of seconds into a pretty formatted data string. The resolution is in seconds. * <p/> * So for example <code>76</code> becomes <code>'1 minute, 16 seconds'</code>, while <code>42</code> becomes <code>'42 seconds'</code> * * @param numSecs the number of seconds in the duration * @param resourceBundle a resouce bundle for i18n * @return a string in readable pretty duration format, using second resolution */ public static String getDurationPrettySecondsResolution(long numSecs, ResourceBundle resourceBundle) { return getDurationPrettySeconds(numSecs, Duration.DAY.getSeconds(), Duration.WEEK.getSeconds(), resourceBundle, true); }
public long getMilliseconds() { return 1000L * getSeconds(); }
/** * Converts a number of seconds into a pretty formatted data string. The resolution is in minutes. So if the number of seconds is greater than a minute, it will * only be shown down top minute resolution. If the number of seconds is less than a minute it will be shown in seconds. * <p/> * So for example <code>76</code> becomes <code>'1 minute'</code>, while <code>42</code> becomes <code>'42 seconds'</code> * * @param numSecs the number of seconds in the duration * @param resourceBundle a resouce bundle for i18n * @return a string in readable pretty duration format, using minute resolution */ public static String getDurationPretty(long numSecs, ResourceBundle resourceBundle) { return getDurationPrettySeconds(numSecs, Duration.DAY.getSeconds(), Duration.WEEK.getSeconds(), resourceBundle, false); }
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); }
/** * Sometimes customers configure the meaning of "day" or "week" to mean something like "1 day = 8 hours". * * @param secondsPerDay how many seconds are in a "day" * @param secondsPerWeek how many seconds are in a "week" (based on number of days per week and hours per day) * @return number of seconds in the duration, taking into account the modified definition of "day" and "week" */ public long getModifiedSeconds(final long secondsPerDay, final long secondsPerWeek) { return getSeconds(); }
/** * Converts a number of seconds into a pretty formatted data string. The resolution is in seconds. * <p/> * So for example <code>76</code> becomes <code>'1 minute, 16 seconds'</code>, while <code>42</code> becomes <code>'42 seconds'</code> * * @param numSecs the number of seconds in the duration * @param resourceBundle a resouce bundle for i18n * @return a string in readable pretty duration format, using second resolution */ public static String getDurationPrettySecondsResolution(long numSecs, ResourceBundle resourceBundle) { return getDurationPrettySeconds(numSecs, Duration.DAY.getSeconds(), Duration.WEEK.getSeconds(), resourceBundle, true); }
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 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()); }