on 02-28-2012 4:07 AM
Hi All,
Hope you are doing good !!!
I have a requirement where i need to write an UDF(user defined function). Please help me in writing the code for below logic-
I am getting my Input as 111213 where 11 denotes HH 12 denotes mm 13 denotes ss. I need ti insert : between hh:mm:ss
Please help me achieving a code for below logic
I have used standard date transformate function, there i am getting spaces as separator in my input resulting an errors i am sending without spaces.
Regards,
Vijay Kumar.
Hi Vijay,
As rightly mentioned by Mark, you can use standard Date transformations to convert time format. Create a pattern(in dateTrans) with desired separators and transform as per your need.
Using standard functions, whenever you can, instead of UDF's is recommended.
Regards,
Nikhil
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
am getting my Input as 111213 where 11 denotes HH 12 denotes mm 13 denotes ss. I need ti insert : between hh:mm:ss
u try below udf:
source field(111213) -> udf(timeformat)-> targetfield(11:12:13)
udf:
String timeformat(String a, Container container) throws StreamTransformationException{
a = a.substring(0,2) + ":" + a.substring(2,4) + ":" + a.substring(4,a.length());
return a;
Edited by: bhavanisankar.solasu on Feb 28, 2012 10:54 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
I am getting my Input as 111213 where 11 denotes HH 12 denotes mm 13 denotes ss. I need ti insert : between hh:mm:ss
Please help me achieving a code for below logic
I have used standard date transformate function, there i am getting spaces as separator in my input resulting an errors i am sending without spaces.
What do you mean by spaces? Can you try the mapping below?
inputDate -> replaceString -> dateTrans(inputDateFormat: HHmmss outputDateFormat: HH:mm:ss) -> target
Constant: -> /
Constant:-> /
Hope this helps,
Mark
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.