cancel
Showing results for 
Search instead for 
Did you mean: 

UDF(user defined function) for standard date transformate function,

Former Member
0 Kudos

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.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

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

Former Member
0 Kudos

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

markangelo_dihiansan
Active Contributor
0 Kudos

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