Adding leading zero

Post your questions and help other users.

Moderator: Martin

Post Reply
User avatar
digitalstone
Posts: 342
Joined: 21 Oct 2017 12:36
Location: The Netherlands

Adding leading zero

Post by digitalstone » 05 Apr 2021 01:15

I'm calculating with hex color values for a progress bar.
And the part where i'm converting the individual RGB values doesn't let me have a '0' as a first character.

For example:
080F00 results in 8F0

I'm using this function to convert decimal to hexadecimal:

Code: Select all

hex = callJavaStaticMethod("java.lang.Integer", "toHexString(int)", newSubCol);
No matter what i do, it either results into errors, or just doesn't give me the leading '0'.

Code: Select all

concat("0", hex)
Doesn't work.

Code: Select all

"0" + hex
Also doesn't work.

Working with 'numberformat' and regex also lead to nothing.


Does anyone know? This is just silly.
Phone: LG Nexus 5X (rooted vanilla Android 7.1.2)

User avatar
digitalstone
Posts: 342
Joined: 21 Oct 2017 12:36
Location: The Netherlands

Re: Adding leading zero

Post by digitalstone » 05 Apr 2021 16:18

Nevermind... i made a rookie mistake -_-

I used this. But i forgot the initialization:

Code: Select all

"{concat("0", hex)}"

Should have been this:

Code: Select all

hex = "{concat("0", hex)}"
Phone: LG Nexus 5X (rooted vanilla Android 7.1.2)

Post Reply