Class FormatUtil
java.lang.Object
com.inductiveautomation.ignition.common.FormatUtil
- 
Nested Class SummaryNested Classes
- 
Field SummaryFields
- 
Method SummaryModifier and TypeMethodDescriptionstatic booleanReturns true if the given throwable uses a custom implementation of toString()static StringformatByteSize(long numBytes) Formats a size of bytes, appropriately rounding to bytes, kb, mb, etcstatic StringformatDateFull(Date value) Returns a date formated to yyyy-MM-dd hh:mm:ss.Sstatic StringformatDuration(long millis) Formats a number of milliseconds as a human-readable string, like "5 hours, 35 minutes, 28 seconds"static StringformatDuration(long millis, FormatUtil.DurationFormatStyle style) static StringformatDuration(Locale locale, long millis) Formats a number of milliseconds as a human-readable string, like "5 hours, 35 minutes, 28 seconds"static StringformatDuration(Locale locale, long millis, FormatUtil.DurationFormatStyle style) static StringformatDuration(Locale locale, long millis, FormatUtil.DurationFormatStyle style, boolean alwaysShowMillis) static StringformatDurationSince(long millisStart) Shortcut, equivalent to formatDuration(System.currentTimeMillis()-millisStart)static StringformatDurationSince(long millisStart, FormatUtil.DurationFormatStyle style) static StringformatDurationSinceNano(long nanoStart) Convenience function for using nanoTime for diffs.static StringformatSafe(String value, Object... formatArgs) Performs String.format() on the value, with the provided args, but catches the IllegalFormatException that the function might throw.static StringformatSafe(org.apache.log4j.Logger log, String value, Object... formatArgs) Performs String.format() on the value, with the provided args, but catches the IllegalFormatException that the function might throw.static DecimalFormatgetCurrencyInstance(Locale locale) static DecimalFormatgetDecimalFormat(String pattern) Java 9 changed how format symbols are searched, which causes issues for some locales: the symbol returned doesn't match what the user will typically enter from their keyboard.static DecimalFormatgetDecimalFormat(String pattern, Locale locale) Java 9 changed how format symbols are searched, which causes issues for some locales: the symbol returned doesn't match what the user will typically enter from their keyboard.static DecimalFormatSymbolsJava 9 changed how format symbols are searched, which causes issues for some locales: the symbol returned doesn't match what the user will typically enter from their keyboard.static DecimalFormatSymbolsgetDecimalFormatSymbols(Locale locale) Java 9 changed how format symbols are searched, which causes issues for some locales: the symbol returned doesn't match what the user will typically enter from their keyboard.static DecimalFormatgetIntegerInstance(Locale locale) static DecimalFormatgetNumberInstance(Locale locale) static DecimalFormatgetPercentInstance(Locale locale) static Stringstatic Stringstatic booleanisValidEmailFormat(String email) 
- 
Field Details- 
EMAIL_PATTERN
 
- 
- 
Method Details- 
formatByteSizeFormats a size of bytes, appropriately rounding to bytes, kb, mb, etc
- 
formatDurationSinceShortcut, equivalent to formatDuration(System.currentTimeMillis()-millisStart)
- 
formatDurationSinceNanoConvenience function for using nanoTime for diffs. Note, however, that internally the value is converted to milliseconds, so this is not useful for formatting sub-millisecond values.
- 
formatDurationFormats a number of milliseconds as a human-readable string, like "5 hours, 35 minutes, 28 seconds"
- 
formatDurationFormats a number of milliseconds as a human-readable string, like "5 hours, 35 minutes, 28 seconds"
- 
formatDurationpublic static String formatDuration(Locale locale, long millis, FormatUtil.DurationFormatStyle style) 
- 
formatDurationpublic static String formatDuration(Locale locale, long millis, FormatUtil.DurationFormatStyle style, boolean alwaysShowMillis) 
- 
formatDurationSince
- 
formatDuration
- 
customToStringReturns true if the given throwable uses a custom implementation of toString()
- 
getStacktraceCompact
- 
getStacktraceFull
- 
formatDateFullReturns a date formated to yyyy-MM-dd hh:mm:ss.S
- 
formatSafePerforms String.format() on the value, with the provided args, but catches the IllegalFormatException that the function might throw. If formatArgs is null, no operation is performed and the value is returned.
- 
formatSafepublic static String formatSafe(@Nullable org.apache.log4j.Logger log, @Nullable String value, @Nullable Object... formatArgs) Performs String.format() on the value, with the provided args, but catches the IllegalFormatException that the function might throw. If formatArgs is null, no operation is performed and the value is returned. If the logger parameter is not null, a warning will be logged if an error occurs.
- 
getDecimalFormatSymbolsJava 9 changed how format symbols are searched, which causes issues for some locales: the symbol returned doesn't match what the user will typically enter from their keyboard. This overrides to the much more common symbol. This method should _always_ be used instead of getting a instance directly. See FB14239Also, do not hang on to an instance of dfs if the locale could have changed between uses. Get a new set each time. - Returns:
- DecimalFormatSymbols for the default locale, with appropriate changes
 
- 
getDecimalFormatSymbolsJava 9 changed how format symbols are searched, which causes issues for some locales: the symbol returned doesn't match what the user will typically enter from their keyboard. This overrides to the much more common symbol. This method should _always_ be used instead of getting a instance directly. See FB14239- Returns:
- DecimalFormatSymbols for the given locale, with appropriate changes
 
- 
getDecimalFormatJava 9 changed how format symbols are searched, which causes issues for some locales: the symbol returned doesn't match what the user will typically enter from their keyboard. This overrides to the much more common symbol. This method should _always_ be used instead of getting a instance directly. See FB14239Also, do not hang on to an instance of DecimalFormat if the locale could have changed between uses. Get a new instance each time. - Parameters:
- pattern- Format pattern
- Returns:
- DecimalFormat with appropriate symbol changes for the default locale. Not null.
 
- 
getDecimalFormatJava 9 changed how format symbols are searched, which causes issues for some locales: the symbol returned doesn't match what the user will typically enter from their keyboard. This overrides to the much more common symbol. This method should _always_ be used instead of getting a instance directly. See FB14239Also, do not hang on to an instance of DecimalFormat if the locale could have changed between uses. Get a new instance each time. - Parameters:
- pattern- Format pattern
- locale- Locale for formatting
- Returns:
- DecimalFormat with appropriate symbol changes for the given locale. Not null.
 
- 
getIntegerInstance
- 
getCurrencyInstance
- 
getNumberInstance
- 
getPercentInstance
- 
isValidEmailFormat
 
-