Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Write Table now available in Qlik Cloud Analytics: Read Blog
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Formating String when execute String.valueOf(My_field)

Hello.
First i have a integer value i want to string. Then i use String.valueOf(My_Field).
But if the value is 3 i get in my string "3" or i would like to have "03".
An idea please.
I surch for a Format.... method but no results yet.
Thanks
Labels (2)
3 Replies
Anonymous
Not applicable
Author

Hello
Try
String.valueOf(My_Field).length()<2?"0"+String.valueOf(My_Field):String.valueOf(My_Field)

Best regards

shong
Anonymous
Not applicable
Author

I use this in tMap to convert a integer between 0 to 99, to a 2 charcaters String
StringHandling.CHANGE(String.format("%2.0f",ROW1.FIELD)," ","0");
"%2.0f" is format of java printf syntaxe
String.format is talend function
StringHandling.CHANGE is talend function
Anonymous
Not applicable
Author

Shong and SDjecepap i thank you very much.