Search code examples
mulepaddingdatamapperdataweave

Padding zeros on mulesoft


Im just wondering if it is possible to issue a format string using datamapper/dataweave to have a fixed length on a number and have padded zeros to complete the length?

something like

String.format("%056", variable_number);

I tried this on datamapper but it doesnt work. anything I missed?


Solution

  • D,

    In dataweave, you can simply format the number like -

    data: 5 as :string {format:"00000"}
    

    This will output 00005. Number will be padded with 0 if original length is less than number of 0's. eg. 123 -> 00123.

    Hope that helps!