Class TextFormatting

java.lang.Object
de.eldoria.eldoutilities.utils.TextFormatting

public final class TextFormatting extends Object
  • Method Details

    • fillString

      public static String fillString(String string, int fill)
      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 fill
      fill - Desired String length
      Returns:
      filled string.
    • getRangeAsString

      public static String getRangeAsString(String delimiter, String[] source, int from, int to)
      Returns a range of a string array as string.
      Parameters:
      delimiter - delimiter for string join
      source - source array
      from - 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

      public static String cropText(String string, String endSequence, int maxChars, boolean keepWords)
      Trims a text to the desired length. Returns unmodified input if max chars is larger or equal string.length().
      Parameters:
      string - String to trim
      endSequence - 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

      public static String mapBooleanTo(boolean bool, String trueTo, String falseTo)
      Changes the boolean in to a specified String.
      Parameters:
      bool - boolean value
      trueTo - value if true
      falseTo - value if false
      Returns:
      bool as string representative.
    • getTimeAsString

      public static String getTimeAsString()
      Get the current time as string.
      Returns:
      time in format: HH:mm dd.MM.yyyy