<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Left-Padding Integer With Zeroes in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Left-Padding-Integer-With-Zeroes/m-p/2249116#M33758</link>
    <description>or, finally, you can use
&lt;BR /&gt;
&lt;PRE&gt;String.format("%04d", row1.myNumber)&lt;/PRE&gt;
&lt;BR /&gt;if your data type is Integer rather than int, you may want to perform some null testing first, and take appropriate action.</description>
    <pubDate>Fri, 15 Jul 2016 11:04:17 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2016-07-15T11:04:17Z</dc:date>
    <item>
      <title>Left-Padding Integer With Zeroes</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Left-Padding-Integer-With-Zeroes/m-p/2249113#M33755</link>
      <description>I have an integer field in tMap, which may have integers from 1 to 100, for example. How can I output a 4-character string field with zeroes on the left?&amp;nbsp; For example, the integer '1' would be '0001'.&amp;nbsp; The integer '100' would be '0100'.&lt;BR /&gt;Thanks in advance,&lt;BR /&gt;HL&lt;BR /&gt;Fort Myers, FL</description>
      <pubDate>Fri, 02 Jan 2015 17:30:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Left-Padding-Integer-With-Zeroes/m-p/2249113#M33755</guid>
      <dc:creator>HLeyes</dc:creator>
      <dc:date>2015-01-02T17:30:06Z</dc:date>
    </item>
    <item>
      <title>Re: Left-Padding Integer With Zeroes</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Left-Padding-Integer-With-Zeroes/m-p/2249114#M33756</link>
      <description>&lt;PRE&gt;&lt;BR /&gt; &amp;nbsp; /**&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; * formats the number&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; *&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; * {Category} NumberUtil&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; *&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; * {talendTypes} String&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; *&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; * {param} Integer(1234) number: number to format&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; * {param} Integer(6) lengthWithLeadingZeros: length with leading zeros&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; *&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; * {example} numberToString(1234, 6) result: 001,234&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; *&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; */&lt;BR /&gt;public static String numberToString(Integer number, int lengthWithLeadingZeros) {&lt;BR /&gt; if (number != null) {&lt;BR /&gt; String s = String.valueOf(number);&lt;BR /&gt; String rawString = s.replace(".", "").replace(",", "");&lt;BR /&gt; System.out.println(rawString);&lt;BR /&gt; if (lengthWithLeadingZeros &amp;gt; rawString.length()) {&lt;BR /&gt; &amp;nbsp;StringBuilder sb = new StringBuilder();&lt;BR /&gt; &amp;nbsp;for (int i = rawString.length(); i &amp;lt; lengthWithLeadingZeros; i++) {&lt;BR /&gt; &amp;nbsp;sb.append('0');&lt;BR /&gt; &amp;nbsp;}&lt;BR /&gt; &amp;nbsp;sb.append(s);&lt;BR /&gt; &amp;nbsp;return sb.toString();&lt;BR /&gt; } else {&lt;BR /&gt; &amp;nbsp;return s;&lt;BR /&gt; }&lt;BR /&gt; } else {&lt;BR /&gt; return "";&lt;BR /&gt; }&lt;BR /&gt;}&lt;BR /&gt;&lt;/PRE&gt; 
&lt;BR /&gt;Create a routine called e.g. NumberUtil and add this method. 
&lt;BR /&gt;Call this in an expression like: 
&lt;BR /&gt; 
&lt;BR /&gt; 
&lt;PRE&gt;Numberutil.numberToString(row1.my_int_value, 9)&lt;/PRE&gt; 
&lt;BR /&gt; 
&lt;BR /&gt;this will fill the integer to a string length of 9 with the necessary zeros.</description>
      <pubDate>Sat, 03 Jan 2015 11:19:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Left-Padding-Integer-With-Zeroes/m-p/2249114#M33756</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-01-03T11:19:16Z</dc:date>
    </item>
    <item>
      <title>Re: Left-Padding Integer With Zeroes</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Left-Padding-Integer-With-Zeroes/m-p/2249115#M33757</link>
      <description>Hi- 
&lt;BR /&gt;use below expression in Tmap if ur column is string. 
&lt;BR /&gt; 
&lt;FONT size="2"&gt;StringHandling.RIGHT(("0000"&lt;/FONT&gt; 
&lt;FONT size="2"&gt;+row1.columnname ),4).&lt;/FONT&gt; 
&lt;BR /&gt; 
&lt;FONT size="2"&gt;Regards-&lt;/FONT&gt; 
&lt;BR /&gt; 
&lt;FONT size="2"&gt;Raghav K&lt;/FONT&gt;</description>
      <pubDate>Fri, 15 Jul 2016 10:17:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Left-Padding-Integer-With-Zeroes/m-p/2249115#M33757</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-07-15T10:17:47Z</dc:date>
    </item>
    <item>
      <title>Re: Left-Padding Integer With Zeroes</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Left-Padding-Integer-With-Zeroes/m-p/2249116#M33758</link>
      <description>or, finally, you can use
&lt;BR /&gt;
&lt;PRE&gt;String.format("%04d", row1.myNumber)&lt;/PRE&gt;
&lt;BR /&gt;if your data type is Integer rather than int, you may want to perform some null testing first, and take appropriate action.</description>
      <pubDate>Fri, 15 Jul 2016 11:04:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Left-Padding-Integer-With-Zeroes/m-p/2249116#M33758</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-07-15T11:04:17Z</dc:date>
    </item>
    <item>
      <title>Re: Left-Padding Integer With Zeroes</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Left-Padding-Integer-With-Zeroes/m-p/2249117#M33759</link>
      <description>Apache Commons make this easy 
&lt;BR /&gt; 
&lt;PRE&gt;org.apache.commons.lang.StringUtils.leftPad(nationalRegisterNumber, 11, '0')&lt;/PRE&gt;</description>
      <pubDate>Mon, 12 Sep 2016 13:27:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Left-Padding-Integer-With-Zeroes/m-p/2249117#M33759</guid>
      <dc:creator>vharcq</dc:creator>
      <dc:date>2016-09-12T13:27:04Z</dc:date>
    </item>
    <item>
      <title>Re: Left-Padding Integer With Zeroes</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Left-Padding-Integer-With-Zeroes/m-p/2249118#M33760</link>
      <description>&lt;P&gt;for integer&amp;nbsp; datatype...how to write right paded with space&lt;/P&gt;&lt;DIV class="lia-spoiler-container"&gt;&lt;A class="lia-spoiler-link" href="#" rel="nofollow noopener noreferrer"&gt;Spoiler&lt;/A&gt;&lt;NOSCRIPT&gt; (Highlight to read)&lt;/NOSCRIPT&gt;&lt;DIV class="lia-spoiler-border"&gt;&lt;DIV class="lia-spoiler-content"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;NOSCRIPT&gt;&lt;DIV class="lia-spoiler-noscript-container"&gt;&lt;DIV class="lia-spoiler-noscript-content"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/NOSCRIPT&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;s&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jul 2018 13:57:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Left-Padding-Integer-With-Zeroes/m-p/2249118#M33760</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-07-31T13:57:57Z</dc:date>
    </item>
  </channel>
</rss>

