/** * 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); }
/** * 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()); }
public static Object instantiateClass(String name, Object[] constructorArgs) throws ClassNotFoundException, SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException { Class clazz = ClassLoaderUtils.loadClass(name, ClassHelper.class); return instantiateClass(clazz, constructorArgs); } }
private static void run(String sourceName, InputStream in, ImageInfo imageInfo, boolean verbose) { imageInfo.setInput(in); imageInfo.setDetermineImageNumber(true); imageInfo.setCollectComments(verbose); if (imageInfo.check()) { print(sourceName, imageInfo, verbose); } }
public static Properties getProperties(String resource, Class callingClass) { return getPropertiesFromStream(ClassLoaderUtils.getResourceAsStream(resource, callingClass)); }
public String xmlEscape(final String text) { return XMLUtils.escape(text); } }
/** * This is used by the WebWork tags as a bean * Despite the name it doesn't actually format a duration string. It takes a long. * * @param l a duration in seconds * @return a pretty formatted version of the duration * @see #formatDurationPretty * @deprecated You should be calling formatDurationPretty */ public String formatDurationString(long l) { return DateUtils.getDurationPretty(l, resourceBundle); }
public String removeHtmlBreaks(String str) { str = StringUtils.replaceAll(str, "<br>", ""); str = StringUtils.replaceAll(str, "<br/>", ""); str = StringUtils.replaceAll(str, "<br />", ""); str = StringUtils.replaceAll(str, "<p>", ""); str = StringUtils.replaceAll(str, "</p>", ""); return str; }
/** * @return True if both are null or equal, otherwise returns false */ public static boolean isIdentical(Object a, Object b) { return !isDifferent(a, b); }
/** * Get a pretty formatted duration for the given number of seconds. (e.g. "4 days, 2 hours, 30 minutes") * * @param numSecs the number of seconds in the duration * @param secondsPerDay the number of seconds in a "day" * @param secondsPerWeek the number of seconds in a "week" * @param resourceBundle the bundle containing translations for the strings used in the pretty string (e.g. "days") * @return the formatted pretty duration */ public static String getDurationPrettySeconds(long numSecs, long secondsPerDay, long secondsPerWeek, ResourceBundle resourceBundle) { return getDurationPrettySeconds(numSecs, secondsPerDay, secondsPerWeek, resourceBundle, false); }
/** * 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()); }
/** * 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 static Object instantiateClass(String name, Object[] constructorArgs) throws ClassNotFoundException, SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException { Class clazz = ClassLoaderUtils.loadClass(name, ClassHelper.class); return instantiateClass(clazz, constructorArgs); } }
/** * This is used by the Velocity templates as a bean * * @param l a duration in seconds * @return a pretty formatted version of the duration */ public String formatDurationPretty(long l) { return DateUtils.getDurationPretty(l, resourceBundle); }
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 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); }
/** * 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); }
private static String getDurationPrettySeconds(long numSecs, long secondsPerDay, long secondsPerWeek, ResourceBundle resourceBundle, boolean secondsDuration) { return getDurationPrettySeconds(numSecs, Duration.YEAR.getSeconds(), secondsPerDay, secondsPerWeek, resourceBundle, secondsDuration); }
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); }
/** * 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); }