StringUtil

open class StringUtil

Some assorted utility methods for dealing with Strings.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
val LONG_TIME_FORMAT: String = "%d:%02d:%02d"
Format string used for long time expressions which include hours.
Link copied to clipboard
val SHORT_TIME_FORMAT: String = "%02d:%02d"
Format string used for short time expressions which are less than an hour.
Link copied to clipboard
val SHORTER_TIME_FORMAT: String = "%01d:%02d"
Format string used for short time expressions which are less than ten minutes.

Functions

Link copied to clipboard
open fun isEmpty(str: String): Boolean
Determines if given string is empty or null.
Link copied to clipboard
open fun join(stringsToJoin: Array<String>, separator: String): String
Joins the Strings in the given array together into a single String using the specified separator String.
open fun join(stringsToJoin: List<String>, separator: String): String
Joins the Strings in the given List together into a single String using the specified separator String.
Link copied to clipboard
open fun replaceAll(template: CharSequence, sources: Array<String>, destinations: Array<CharSequence>): CharSequence
This method is based on Android's replace and extends its functionality by replacing all instances of each String specified in the sources parameter with the associated destination CharSequence.
Link copied to clipboard
open fun stringForTime(milliseconds: Long): String
Formats the given time duration value (in milliseconds) as a time string in one of the following formats:
  • HH:MM:SS where the timeframe is greater than 1 hour
  • MM:SS where the timeframe is less than an hour
  • M:SS where the timeframe is less than ten minutes