List of utility methods to do Zero Format
String | zeroFill(int value, int fieldWidth) Returns a zero-filled string. StringBuilder buf = new StringBuilder(); buf.append(value); while (buf.length() < fieldWidth) { buf.insert(0, ZERO); return buf.toString(); |
String | zerofill(int x, int desiredWidth) fills the left side of a number with zeros e.g. StringBuffer buf = new StringBuffer(); if (x < 0) { buf.append("-"); desiredWidth--; x = -x; while (desiredWidth > 7) { buf.append("0"); ... |
String | zeroFillString(String originalString, int numZeros) zero Fill String if (originalString.length() < numZeros) { int zerosToAdd = numZeros - originalString.length(); for (int i = 0; i < zerosToAdd; i++) { originalString = "0" + originalString; return originalString; |
String | zeroFormat(Integer source) zero Format String stringSource = String.valueOf(source); if (stringSource.length() >= 3) return source + ""; return String.format("%03d", source); |
String | zeroFormattedStr(int number, int length) zero Formatted Str return zeroFormattedStr((long) number, length); |
int | zeroIfNull(Integer i) converts an Integer to an int , mapping null to 0 and mapping Integer(0) to 0 also.
final int result = (i == null) ? 0 : i; assert !(i == null) || (result == 0); assert !(i != null) || (result == i); return result; |
int | zeroIfNull(Integer i) zero If Null return i != null ? i.intValue() : 0;
|
int | zeroIfNullStrict(Integer i) converts an Integer to an int , mapping null to 0 .
final int result; if (i == null) { result = 0; } else { result = i; if (result == 0) { throw new IllegalArgumentException("langutils.integer.not.allowed.exception"); assert !(i == null) || (result == 0); assert !((i != null) && (i != 0)) || (result == i); return result; |
byte[] | zeroInterval(byte[] x, int start, int end) zero Interval final byte[] result = x.clone(); for (int i = start; i < end; i++) result[i] = (byte) 0; return result; |
long | zeroLowerBits(long bits, int nBits) Zeroes the lower n bits of a bitstring. long invMask = (1L << nBits) - 1L; long mask = ~invMask; long zeroed = bits & mask; return zeroed; |