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
bytesToHex
(byte[] bytes) static float
calculateWidth
(CharSequence text, com.badlogic.gdx.graphics.g2d.BitmapFont font) static com.badlogic.gdx.utils.StringBuilder
commaSeparatedNumber
(long number) static com.badlogic.gdx.utils.ByteArray
compactBytes
(byte[] bytes, int offset, int count) static com.badlogic.gdx.utils.StringBuilder
compactNumber
(double number, boolean withPoint) static com.badlogic.gdx.utils.StringBuilder
compactNumber
(double number, int pointPrecision) Форматирует число так, чтобы всегда было 3 цифры 1913 => 1.91K 28415 => 28.4K 913275 => 913K ...static com.badlogic.gdx.utils.StringBuilder
compactNumber
(double number, int pointPrecision, boolean trimLeadingZeros) static com.badlogic.gdx.utils.StringBuilder
digestTime
(int seconds) static com.badlogic.gdx.utils.StringBuilder
digestTime
(int seconds, boolean prependZeroHours) static String
distinguishableString
(int i) static CharSequence
fitToWidth
(CharSequence text, float width, com.badlogic.gdx.graphics.g2d.BitmapFont font, CharSequence truncate) static byte[]
fromBase64
(String string) static byte[]
fromCompactBase64
(String string) static ByteArrayOutputStream
fromCompactBytes
(byte[] buffer, int offset, int size) static com.badlogic.gdx.utils.StringBuilder
intToString
(int v) static void
static String
static byte[]
md5HashToBytes
(String data) static String
romanNumber
(int number) static String
stringFromCompactBase64
(String string) static String
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 com.badlogic.gdx.utils.StringBuilder
toLowerCase
(CharSequence chars) static com.badlogic.gdx.utils.StringBuilder
toRGB
(com.badlogic.gdx.graphics.Color color) static com.badlogic.gdx.utils.StringBuilder
toUpperCase
(CharSequence chars)
-
Field Details
-
DISTINGUISHABLE_STRING_CHARS
- See Also:
-
DIST_STRING_CHAR_TO_IDX
public static final com.badlogic.gdx.utils.IntIntMap DIST_STRING_CHAR_TO_IDX -
VALID_EMAIL_ADDRESS_REGEX
-
-
Constructor Details
-
StringFormatter
public StringFormatter()
-
-
Method Details
-
bytesToHex
-
toUpperCase
-
toLowerCase
-
toRGB
public static com.badlogic.gdx.utils.StringBuilder toRGB(com.badlogic.gdx.graphics.Color color) - Returns:
- RRGGBB
-
digestTime
public static com.badlogic.gdx.utils.StringBuilder digestTime(int seconds) -
digestTime
public static com.badlogic.gdx.utils.StringBuilder digestTime(int seconds, boolean prependZeroHours) -
timePassed
Форматирует время. 62 -> 1 м 2 с- Parameters:
seconds
- время в секундах- Returns:
- строка вида "8 ч 13 м 7 с"
-
commaSeparatedNumber
public static com.badlogic.gdx.utils.StringBuilder commaSeparatedNumber(long number) -
compactNumber
public static com.badlogic.gdx.utils.StringBuilder compactNumber(double number, int pointPrecision) Форматирует число так, чтобы всегда было 3 цифры 1913 => 1.91K 28415 => 28.4K 913275 => 913K ... pointPrecision работает только на числа до 100 K 3 M 6 B 9 T 12 -
compactNumber
public static com.badlogic.gdx.utils.StringBuilder compactNumber(double number, int pointPrecision, boolean trimLeadingZeros) -
main
-
compactNumber
public static com.badlogic.gdx.utils.StringBuilder compactNumber(double number, boolean withPoint) -
romanNumber
- Parameters:
number
- от 1 до 39- Returns:
- римские цифры
-
distinguishableString
-
toCompactBase64
-
toBase64
-
compactBytes
public static com.badlogic.gdx.utils.ByteArray compactBytes(byte[] bytes, int offset, int count) -
fromCompactBytes
-
fromCompactBase64
-
fromBase64
-
stringToCompactBase64
-
stringFromCompactBase64
-
md5Hash
-
md5HashToBytes
-
calculateWidth
public static float calculateWidth(CharSequence text, com.badlogic.gdx.graphics.g2d.BitmapFont font) -
fitToWidth
public static CharSequence fitToWidth(CharSequence text, float width, com.badlogic.gdx.graphics.g2d.BitmapFont font, CharSequence truncate) -
intToString
public static com.badlogic.gdx.utils.StringBuilder intToString(int v)
-