Originally posted by: MyScreen-Laks
Here is my requirement:
Check the number of decimal places and if it is equal to 3 then move the digit one place to right and if it is equal to 4 then move the digit two places to the right.For ex: a=123.456 returns a=1234.56 and if a=123.4567 then returns a=12345.67
I already did this in Java but I don't know how to implement the same functionality in WTX. Please advice:
Here is the equivalent Java Code:
public String MyAbs(String a,Container container){
int i = a.indexOf(".");
if(i != -1)
{
String subStr = a.substring(i+1);
String substr1 = a.substring(0,i);
String substr2 = a.substring(i+1);
if(subStr.length() ==3)
{
a = substr1 + substr2.charAt(0)+ "." + substr2.substring(1,3);
}
else if(subStr.length() == 4)
{
a = substr1 + substr2.substring(0,2)+ "." + substr2.substring(2,4);
}
else if(subStr.length() == 5)
{
a = substr1 + substr2.substring(0,3)+ "." + substr2.substring(3,5);
}
else if(subStr.length() == 6)
{
a = substr1 + substr2.substring(0,4)+ "." + substr2.substring(4,6);
}
}
return a;
}
#IBMSterlingTransformationExtender#DataExchange#IBM-Websphere-Transformation-Extender