cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping - Add integer to current time

Former Member
0 Kudos

Dear All,

I have a message mapping that I need to add the current time with a integer field, moving to a time field into target message.

Does anybody have idea how to do this,

Regards,

Fernando

Accepted Solutions (1)

Accepted Solutions (1)

prabhu_s2
Active Contributor
0 Kudos

u have date transformation node in mapping. make use of it (here u can get the time alone) and pass this as an input to a udf which also has another input integer. inside udf perform a add function and return the string,...u might need a typecast inside udf else it might throw a dump

Message was edited by:

Prabhu S

Former Member
0 Kudos

Hi,

Unfortunately I don't know JAVA very well, so can you give me an example oh this udf?

Thank's a lot.

Fernando

prabhu_s2
Active Contributor
0 Kudos
TransformDate
(yyyy-mm-ddHH:MM:SS --> HH:MM:SS) -----
                                      |
                                      |----UDF-----Target
Integer(source)------------------------                                                                 

the above is the graphical part and insied the udf we can write more optimized code...since i dont have NWDS i'm unable to provide u the code...will keep u posted on this

Message was edited by:

Prabhu S

prabhu_s2
Active Contributor
0 Kudos

hi

chcek wif this work:

StringTokenizer sTok = new StringTokenizer(STRG, ":");
int hr = Integer.parseInt(sTok.nextToken());
int min = Integer.parseInt(sTok.nextToken());
int sec = Integer.parseInt(sTok.nextToken());
GregorianCalendar today = new GregorianCalendar();
 
GregorianCalendar gc =
new GregorianCalendar(
 today.get(GregorianCalendar.YEAR),
	today.get(GregorianCalendar.MONTH),
	today.get(GregorianCalendar.DAY_OF_MONTH),
	hr,
	min,
	sec);
gc.add(GregorianCalendar.SECOND, Integer.parseInt(INTE));

return gc.getTime();

Former Member
0 Kudos

Hi Prabhu,

I used your function and occured this error:

incompatible types found : java.util.Date required: java.lang.String return gc.getTime(); ^ 1 error

Can you help me to solve this problem?

Thank's a lot for your help.

Fernando

Former Member
0 Kudos

Hi,

just replace <i>return gc.getTime();</i> by:

return gc.getTime().toString();

Thanks,

Rajeev Gupta

Message was edited by:

RAJEEV GUPTA

Former Member
0 Kudos

Hi,

I replaced the code and worked fine.

But now I have the date and the time into the same field with the format:

Thu Mar 01 08:25:58 UTC

I also need to get the date with the format YYYY-MM-DD.

Can you help me?

Thank's a lot.

Fernando

Former Member
0 Kudos

Hi,

in graphical mapping, take the output of UDF and currentDate nodes to concat fnc and take is output to target. just double-click currentDate and give your date format.

UDF -


>

,,,,,,,,,,,,,,,,, concat-------> target

currntDate------>

Thanks,

Rajeev Gupta

Message was edited by:

RAJEEV GUPTA

Message was edited by:

RAJEEV GUPTA

Message was edited by:

RAJEEV GUPTA

Former Member
0 Kudos

HI,

yes correct you can use DateTrans or CurrentDate GM functions , you can achieve it.

Regards

Chilla..

Former Member
0 Kudos

Hi,

I did what you said, but did not work.

It returned "Tru Mar 01 02:24:21 UTC 20072007-03-01"

Tru Mar 01 02:24:21 UTC 2007 is the result of UDF and 2007-03-01 is the current date.

I need to convert the "Tru Mar 01 02:24:21 UTC 20072007-03-01" to "2007-03-01"

Thank's a lot for your help.

Fernando

Former Member
0 Kudos

change the UDF to written only Tru Mar 01 02:24:21 UTC but not Tru

"Mar 01 02:24:21 UTC 2007" then your problem will be sloved or use date conversion and speicy in date conversin mm-DD with out changing the UDF.

Regards

Sreeram.g.Reddy

Former Member
0 Kudos

Hi,

What kind of date conversion may I have to use?

Into Graphical Mapping I used "DateTrans" but I didn't find a format of source.

Thank's a lot for your help.

Fernando

Former Member
0 Kudos

Hi,

<i>I need to convert the "Tru Mar 01 02:24:21 UTC 20072007-03-01" to "2007-03-01"</i> - for this just use currentDate fnc and double click it ....give target format yyyy-MM-dd and you will get it.......

If you want to convert the "Tru Mar 01 02:24:21 UTC 20072007-03-01" to "Tru Mar 01 02:24:21 UTC 2007-03-01" then do below:

choose currentDate and double click it ....give target format -MM-dd and concat UDF with currentDate and then you will get it.....

Thanks,

Rajeev Gupta

Former Member
0 Kudos

currentDate and double click it ....give target format -mm-dd and concat UDF with currentDate.

regards

Sreeram.G.Reddy

Former Member
0 Kudos

Hi,

I used concatenate function with "Tru Mar 01 02:24:21 UTC 2007" and Current Date.

It returned "Tru Mar 01 02:24:21 UTC 20072007-03-01"

The string "Tru Mar 01 02:24:21 UTC 2007" is the result of UDF.

I need to convert the String "Tru Mar 01 02:24:21 UTC 2007" to "2007-03-01"

Is it possible to use only a graphical mapping to do this?

If it's impossible to use only a graphical mapping and I have to need to change UDF can you help me how to do this?

Best Regards.

Fernando

prabhu_s2
Active Contributor
0 Kudos

u need to have this functionality done inside the udf itself.

prabhu_s2
Active Contributor
0 Kudos

also u can try for this:


TransformDate
(yyyy-mm-ddHH:MM:SS --> HH:MM:SS) -----
                                      |
                                      |----UDF-----TransformDate(yyyy-mm-dd hh:mm:ss)----Target
Integer(source)------------------------       

Former Member
0 Kudos

Hi,

I had already tried to do this way but I coundn't use TransformDate Funcion, because I can define the target format but I can't define the souuce format who is the string "Tru Mar 01 02:24:21 UTC 2007".

How can I use the TransformDate function with the source date with the format:

"Tru Mar 01 02:24:21 UTC 2007"?

Best Regards

Fernando

Former Member
0 Kudos

Hi,

Can you help me with an example how to do this funcionality into UDF?

I don't know JAVA very well.

Thanks a lot.

Fernando

Former Member
0 Kudos

Consultor,

used concatenate function with "Tru Mar 01 02:24:21 UTC 2007" and Current Date.

It returned "Tru Mar 01 02:24:21 UTC 20072007-03-01"

when you use current date pass this input to date conversion and in date conversion use -mm-DD only and concat this with our UDF i.e.

Tru Mar 01 02:24:21 UTC 2007 which should give

Tru Mar 01 02:24:21 UTC 2007-03-01

Regards

Sreeram.G.Reddy

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

<i> I need to add the current time with a integer field</i> - what is your req....can you explain in more detail with an example.... then i may be able to help you.

Thanks,

Rajeev Gupta

Former Member
0 Kudos

Just date Function standard function provided by XI and concat the date with the integer and send it to target. for conaction use concat function provded by XI

Regards

Sreeram.G.Reddy