Package de.eldoria.eldoutilities.utils
Class TextFormatting
java.lang.Object
de.eldoria.eldoutilities.utils.TextFormatting
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
Trims a text to the desired length.static String
fillString
(String string, int fill) Appends white spaces to a string to match the given length.static String
getRangeAsString
(String delimiter, String[] source, int from, int to) Returns a range of a string array as string.static String
Get the current time as string.static String
mapBooleanTo
(boolean bool, String trueTo, String falseTo) Changes the boolean in to a specified String.
-
Method Details
-
fillString
Appends white spaces to a string to match the given length. Returns input if fill is smaller or equal string.length()- Parameters:
string
- String to fillfill
- Desired String length- Returns:
- filled string.
-
getRangeAsString
Returns a range of a string array as string.- Parameters:
delimiter
- delimiter for string joinsource
- source arrayfrom
- start index (included). Use negative counts to count from the last index.to
- end index (excluded). Use negative counts to count from the last index.- Returns:
- range as string
-
cropText
Trims a text to the desired length. Returns unmodified input if max chars is larger or equal string.length().- Parameters:
string
- String to trimendSequence
- end sequence which should be append at the end of the string. included in max chars.maxChars
- max char length.keepWords
- true if no word should be cut.- Returns:
- String with length of maxChars of shorter.
-
mapBooleanTo
Changes the boolean in to a specified String.- Parameters:
bool
- boolean valuetrueTo
- value if truefalseTo
- value if false- Returns:
- bool as string representative.
-
getTimeAsString
Get the current time as string.- Returns:
- time in format: HH:mm dd.MM.yyyy
-