Class StringFormatter

java.lang.Object
com.prineside.tdi2.utils.StringFormatter

public class StringFormatter extends Object
  • Field Details

    • DISTINGUISHABLE_STRING_CHARS

      public static final String DISTINGUISHABLE_STRING_CHARS
      See Also:
    • DIST_STRING_CHAR_TO_IDX

      public static final IntIntMap DIST_STRING_CHAR_TO_IDX
    • VALID_EMAIL_ADDRESS_REGEX

      public static final Pattern VALID_EMAIL_ADDRESS_REGEX
  • Constructor Details

    • StringFormatter

      public StringFormatter()
  • Method Details

    • bytesToHex

      public static String bytesToHex(byte[] bytes)
    • main

      public static void main(String[] args)
    • toUpperCase

      public static StringBuilder toUpperCase(CharSequence chars)
    • toLowerCase

      public static StringBuilder toLowerCase(CharSequence chars)
    • toRGB

      public static StringBuilder toRGB(Color color)
      Returns:
      RRGGBB
    • digestTime

      public static StringBuilder digestTime(int seconds)
    • digestTimeWithZeroHours

      public static StringBuilder digestTimeWithZeroHours(int seconds, boolean prependZeroHours)
    • timePassed

      public static String timePassed(int seconds, boolean appendZeroValues, boolean appendDays)
      Форматирует время. 62 -> 1 м 2 с
      Parameters:
      seconds - время в секундах
      Returns:
      строка вида "8 ч 13 м 7 с"
    • commaSeparatedNumber

      public static StringBuilder commaSeparatedNumber(long number)
    • compactNumberWithPrecision

      public static StringBuilder compactNumberWithPrecision(double number, int pointPrecision)
      Форматирует число так, чтобы всегда было 3 цифры 1913 => 1.91K 28415 => 28.4K 913275 => 913K ... pointPrecision работает только на числа до 100 K 3 M 6 B 9 T 12
    • compactNumberWithPrecisionTrimZeros

      public static StringBuilder compactNumberWithPrecisionTrimZeros(double number, int pointPrecision, boolean trimLeadingZeros)
    • compactNumber

      public static StringBuilder compactNumber(double number, boolean withPoint)
    • romanNumber

      public static String romanNumber(int number)
      Parameters:
      number - от 1 до 39
      Returns:
      римские цифры
    • distinguishableString

      public static String distinguishableString(int i)
    • toCompactBase64

      public static String toCompactBase64(byte[] bytes, int offset, int count)
    • toBase64

      public static String toBase64(byte[] bytes, int offset, int count)
    • compactBytes

      public static ByteArray compactBytes(byte[] bytes, int offset, int count)
    • fromCompactBytes

      public static ByteArrayOutputStream fromCompactBytes(byte[] buffer, int offset, int size)
    • fromCompactBase64

      public static byte[] fromCompactBase64(String string)
    • fromBase64

      public static byte[] fromBase64(String string)
    • stringToCompactBase64

      public static String stringToCompactBase64(String s)
    • stringFromCompactBase64

      public static String stringFromCompactBase64(String string)
    • md5Hash

      public static String md5Hash(String data)
    • bytesMd5Hash

      public static String bytesMd5Hash(byte[] data)
    • md5HashToBytes

      public static byte[] md5HashToBytes(String data)
    • calculateWidth

      public static float calculateWidth(CharSequence text, BitmapFont font)
    • fitToWidth

      public static CharSequence fitToWidth(CharSequence text, float width, BitmapFont font, CharSequence truncate)
    • intToString

      public static StringBuilder intToString(int v)
    • shortenFirstWord

      public static String shortenFirstWord(String s)
      Removes lower-case vowels from the first word it spots (English alphabet)
    • stripTerminalColors

      public static CharSequence stripTerminalColors(String message)
      Removes tags which start with  and end with m Works only for 8 and 16 colors of font / background, styles and style resets Does not work with 256 colors, cursor movements and screen commands (why would you need them in logs in the first place?)