Created
December 23, 2015 16:05
-
-
Save SriniBlog/d950ae2a9d4dc98422b5 to your computer and use it in GitHub Desktop.
This function is similar to PI Standard Function but it won't throw exception like the standard UDF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public String subStrings(String FieldValue, String startPos, String endPos, Container container) throws StreamTransformationException{ | |
String newFieldValue = ""; | |
try{ | |
int istartPos = Integer.parseInt(startPos); | |
int iendPos = Integer.parseInt(endPos); | |
if( startPos.equals("-1") ){ //startPos value is passed as -1 then substring from 0 till the endPos value | |
newFieldValue = FieldValue.substring(0,iendPos); | |
}else if ( endPos.equals("-1") ){ //endPos value is passed as -1 then substring from startPos till end | |
newFieldValue = FieldValue.substring(istartPos); | |
}else{ | |
newFieldValue = FieldValue.substring(istartPos, iendPos); //This is a normal substring with exception block | |
} | |
}catch(Exception ee){ | |
newFieldValue = FieldValue; | |
} | |
return newFieldValue; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment