public class StringBuilderUtil extends Object
| Constructor and Description |
|---|
StringBuilderUtil() |
| Modifier and Type | Method and Description |
|---|---|
static StringBuilder |
appendNumber(StringBuilder stringBuilder,
long value,
int digitCounts)
Append the given number into the
StringBuilder. |
static StringBuilder |
appendNumberForMaxDigit(StringBuilder stringBuilder,
long value,
int digitCounts)
Append the given number into the
StringBuilder. |
static StringBuilder |
appendNumberForMinDigit(StringBuilder stringBuilder,
long value,
int digitCounts)
Append the given number into the
StringBuilder. |
public static StringBuilder appendNumber(StringBuilder stringBuilder, long value, int digitCounts)
StringBuilder. It will be made sure that the number takes exactly the
given number of digit count. If the value exceeds the number of digits than the given number of
digitCounts, it will discard the most significant numbers. And if the value have less
digits than given digitCounts, it will add extra 0 as prefix to the number.
for example value = 10, digitCounts = 3 will append 010 value = 1234, digitCounts = 3 will append 234
stringBuilder - given number will be appended into this instance.value - this value will be appended.digitCounts - number of digits to be appended.StringBuilderpublic static StringBuilder appendNumberForMinDigit(StringBuilder stringBuilder, long value, int digitCounts)
StringBuilder. It will be made sure that the number takes minimum the
given number of digit count. If the value have less digits than given digitCounts,
it will add extra 0 as prefix to the number, otherwise it will append all the digits even if it exceeds the given
digit counts.
for example value = 10, digitCounts = 3 will append 010 value = 1234, digitCounts = 3 will append 1234
stringBuilder - given number will be appended into this instance.value - this value will be appended.digitCounts - minimum number of digits to be appended.StringBuilderpublic static StringBuilder appendNumberForMaxDigit(StringBuilder stringBuilder, long value, int digitCounts)
StringBuilder. It will be made sure that the number takes maximum the
given number of digit count. If the value exceeds the number of digits than the given number of
digitCounts, it will discard the most significant numbers, otherwise it will append all the digits
even if it has fewer digits than given digit counts.
for example value = 10, digitCounts = 3 will append 10 value = 1234, digitCounts = 3 will append 234
stringBuilder - given number will be appended into this instance.value - this value will be appended. If this value is 0, it will add nothing in the given string builder.digitCounts - maximum number of digits to be appended.StringBuilderCopyright © 2023. All rights reserved.