<?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: [resolved] in tJavaRow rounding float to two decimals and use in String in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/resolved-in-tJavaRow-rounding-float-to-two-decimals-and-use-in/m-p/2335340#M103913</link>
    <description>Try this..&lt;BR /&gt;&lt;PRE&gt;output_row.price_ex =  new DecimalFormat("#.##").format((input_row.price/1.21))+"string";&lt;/PRE&gt;</description>
    <pubDate>Tue, 21 May 2013 12:50:00 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2013-05-21T12:50:00Z</dc:date>
    <item>
      <title>[resolved] in tJavaRow rounding float to two decimals and use in String</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-in-tJavaRow-rounding-float-to-two-decimals-and-use-in/m-p/2335339#M103912</link>
      <description>Hi,
&lt;BR /&gt;Can anybody help me with this: With tJavaRow I'm using code below (simplification of actual use)
&lt;BR /&gt;
&lt;PRE&gt;output_row.price_ex = (input_row.price/1.21)+" ex vat price"&lt;/PRE&gt;
&lt;BR /&gt;Challenge: Output has many decimals, but needs to be just two. 
&lt;BR /&gt;FYI: the input is float, the output string
&lt;BR /&gt;I have read that DecimalFormat might be an approach, unfortunately I am a beginner with Java and Talend so I might need an example what code to use exactly instead of the code above.
&lt;BR /&gt;Hope someone can help me out</description>
      <pubDate>Tue, 21 May 2013 11:28:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-in-tJavaRow-rounding-float-to-two-decimals-and-use-in/m-p/2335339#M103912</guid>
      <dc:creator>hvanderborg</dc:creator>
      <dc:date>2013-05-21T11:28:27Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] in tJavaRow rounding float to two decimals and use in String</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-in-tJavaRow-rounding-float-to-two-decimals-and-use-in/m-p/2335340#M103913</link>
      <description>Try this..&lt;BR /&gt;&lt;PRE&gt;output_row.price_ex =  new DecimalFormat("#.##").format((input_row.price/1.21))+"string";&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 May 2013 12:50:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-in-tJavaRow-rounding-float-to-two-decimals-and-use-in/m-p/2335340#M103913</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-05-21T12:50:00Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] in tJavaRow rounding float to two decimals and use in String</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-in-tJavaRow-rounding-float-to-two-decimals-and-use-in/m-p/2335341#M103914</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Try this..&lt;BR /&gt;&lt;PRE&gt;output_row.price_ex =  new DecimalFormat("#.##").format((input_row.price/1.21))+"string";&lt;/PRE&gt;&lt;BR /&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;Thanks, tried but results in this error: "DecimalFormat cannot be resolved to a type". When I google for that it seems I need to add code to import DecimalFormat?</description>
      <pubDate>Tue, 21 May 2013 13:27:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-in-tJavaRow-rounding-float-to-two-decimals-and-use-in/m-p/2335341#M103914</guid>
      <dc:creator>hvanderborg</dc:creator>
      <dc:date>2013-05-21T13:27:52Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] in tJavaRow rounding float to two decimals and use in String</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-in-tJavaRow-rounding-float-to-two-decimals-and-use-in/m-p/2335342#M103915</link>
      <description>output_row.price_ex = new java.text.DecimalFormat("#.##").format(input_row.price/1.21)+"string";</description>
      <pubDate>Wed, 22 May 2013 05:44:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-in-tJavaRow-rounding-float-to-two-decimals-and-use-in/m-p/2335342#M103915</guid>
      <dc:creator>alevy</dc:creator>
      <dc:date>2013-05-22T05:44:45Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] in tJavaRow rounding float to two decimals and use in String</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-in-tJavaRow-rounding-float-to-two-decimals-and-use-in/m-p/2335343#M103916</link>
      <description>Hi havenderborg &lt;BR /&gt;&lt;BR /&gt;yes.. you need to import java.text.DecimalFormat&lt;BR /&gt;or you can do it without any  import using math of java&lt;BR /&gt;try this&lt;BR /&gt;&lt;PRE&gt;      output_row.price_ex =Math.round((input_row.price/1.21)*100)/100f +" ex vat price"&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 May 2013 06:06:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-in-tJavaRow-rounding-float-to-two-decimals-and-use-in/m-p/2335343#M103916</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-05-22T06:06:52Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] in tJavaRow rounding float to two decimals and use in String</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-in-tJavaRow-rounding-float-to-two-decimals-and-use-in/m-p/2335344#M103917</link>
      <description>&lt;BLOCKQUOTE&gt;
 &lt;TABLE border="1"&gt;
  &lt;TBODY&gt;
   &lt;TR&gt;
    &lt;TD&gt;Hi havenderborg &lt;BR /&gt;&lt;BR /&gt;yes.. you need to import java.text.DecimalFormat&lt;BR /&gt;or you can do it without any import using math of java&lt;BR /&gt;try this&lt;BR /&gt;&lt;PRE&gt;      output_row.price_ex =Math.round((input_row.price/1.21)*100)/100f +" ex vat price"&lt;/PRE&gt;&lt;BR /&gt;&lt;/TD&gt;
   &lt;/TR&gt;
  &lt;/TBODY&gt;
 &lt;/TABLE&gt;
&lt;/BLOCKQUOTE&gt;
&lt;BR /&gt;Just tried the Math.round and that worked, many thanks!
&lt;BR /&gt;I did notice it didn't have effect if I try that in an expression in tMap (I would still got many decimals), so tJavaRow will solve it for now. (Perhaps I try java.text.DecimalFormat as well later)</description>
      <pubDate>Sun, 09 Jun 2013 11:45:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-in-tJavaRow-rounding-float-to-two-decimals-and-use-in/m-p/2335344#M103917</guid>
      <dc:creator>hvanderborg</dc:creator>
      <dc:date>2013-06-09T11:45:11Z</dc:date>
    </item>
  </channel>
</rss>

