the 000016 is a Long value. So when i call .toStri...
# android
p
the 000016 is a Long value. So when i call .toString on it, the zeros are gone. And it returns only 16.
e
where did you get the 000016 from. as a Long, it does not have the concept of leading decimal zeros - it has a 64-bit two's-complement binary representation.
c
A Long of
16L
is not the same as the String
"000016"
. Once a String is parsed to Long (
"000016".toLong()
) all you have left is the raw 64-bit representation of that number in memory, there’s no reason it should print with 4 leading zeros at that point. You’ll have to format that number with
String.format
, or manually pad the default String representation (
.toString().padStart(6, '0')
)