Wednesday, September 16, 2015

How to round off decimal to whole number

To get the ceiling value:

4143.77 to 4144

In a tmap


var1=java.lang.Math.ceil((double)Double.parseDouble(column))


when you do this the value will come out as

4144.0


to remove the trailing ".0" use below function:

(int) Math.round(Var.var1)




Wednesday, August 26, 2015

How to Hash Code any column in talend

Need to write an code in routine


public class GetHashCode {
public static String GetHashCode1(String strCode)
    {
    java.security.MessageDigest msg;
    String digest1 = "";
try
{
msg = java.security.MessageDigest.getInstance("MD5");
msg.update(strCode.getBytes(), 0, strCode.length());
digest1 =  new java.math.BigInteger(1, msg.digest()).toString(16);
}
catch (NoSuchAlgorithmException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
return digest1.toUpperCase();
    }
}