Package com.prineside.tdi2.utils
Class StringFormatter
java.lang.Object
com.prineside.tdi2.utils.StringFormatter
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
bytesMd5Hash
(byte[] data) static String
bytesToHex
(byte[] bytes) static float
calculateWidth
(CharSequence text, BitmapFont font) static StringBuilder
commaSeparatedNumber
(long number) static ByteArray
compactBytes
(byte[] bytes, int offset, int count) static StringBuilder
compactNumber
(double number, boolean withPoint) static StringBuilder
compactNumberWithPrecision
(double number, int pointPrecision) Форматирует число так, чтобы всегда было 3 цифры 1913 => 1.91K 28415 => 28.4K 913275 => 913K ...static StringBuilder
compactNumberWithPrecisionTrimZeros
(double number, int pointPrecision, boolean trimLeadingZeros) static StringBuilder
digestTime
(int seconds) static StringBuilder
digestTimeWithZeroHours
(int seconds, boolean prependZeroHours) static String
distinguishableString
(int i) static CharSequence
fitToWidth
(CharSequence text, float width, BitmapFont font, CharSequence truncate) static byte[]
fromBase64
(String string) static byte[]
fromCompactBase64
(String string) static ByteArrayOutputStream
fromCompactBytes
(byte[] buffer, int offset, int size) static StringBuilder
intToString
(int v) static void
static String
static byte[]
md5HashToBytes
(String data) static String
romanNumber
(int number) static String
Removes lower-case vowels from the first word it spots (English alphabet)static String
stringFromCompactBase64
(String string) static String
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?)static String
timePassed
(int seconds, boolean appendZeroValues, boolean appendDays) Форматирует время.static String
toBase64
(byte[] bytes, int offset, int count) static String
toCompactBase64
(byte[] bytes, int offset, int count) static StringBuilder
toLowerCase
(CharSequence chars) static StringBuilder
static StringBuilder
toUpperCase
(CharSequence chars)
-
Field Details
-
DISTINGUISHABLE_STRING_CHARS
- See Also:
-
DIST_STRING_CHAR_TO_IDX
-
VALID_EMAIL_ADDRESS_REGEX
-
-
Constructor Details
-
StringFormatter
public StringFormatter()
-
-
Method Details
-
bytesToHex
-
main
-
toUpperCase
-
toLowerCase
-
toRGB
- Returns:
- RRGGBB
-
digestTime
-
digestTimeWithZeroHours
-
timePassed
Форматирует время. 62 -> 1 м 2 с- Parameters:
seconds
- время в секундах- Returns:
- строка вида "8 ч 13 м 7 с"
-
commaSeparatedNumber
-
compactNumberWithPrecision
Форматирует число так, чтобы всегда было 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
-
romanNumber
- Parameters:
number
- от 1 до 39- Returns:
- римские цифры
-
distinguishableString
-
toCompactBase64
-
toBase64
-
compactBytes
-
fromCompactBytes
-
fromCompactBase64
-
fromBase64
-
stringToCompactBase64
-
stringFromCompactBase64
-
md5Hash
-
bytesMd5Hash
-
md5HashToBytes
-
calculateWidth
-
fitToWidth
public static CharSequence fitToWidth(CharSequence text, float width, BitmapFont font, CharSequence truncate) -
intToString
-
shortenFirstWord
Removes lower-case vowels from the first word it spots (English alphabet) -
stripTerminalColors
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?)
-