cancel
Showing results for 
Search instead for 
Did you mean: 

Time stamp

Former Member
0 Kudos

Hi all,

I want to add <b>time stamp</b> to a date field in my mapping. I want the time in <b>12 hours format</b> and I want to append AM or PM depending on the time of the day. Is there any way to do this <b>without writing an UDF</b>?

Thanks in advance.

Regards,

Divija.

Accepted Solutions (1)

Accepted Solutions (1)

bhavesh_kantilal
Active Contributor
0 Kudos

Divija,

Without a UDF, I dont think this is possible.

Reason you would need to get the System time and this can be got using an UDF only.!

Get the system time and do the corresponding logis for the same.

Regards

Bhavesh

Answers (7)

Answers (7)

Former Member
0 Kudos

Hi All,

please let's try to avoid posting twice the same response without giving any further value, so the thread will not loose it's usefulness

Kind Regards,

Sergio

Former Member
0 Kudos

Hi all,

I found a way to solve it, but not without the use of an UDF. I am just sharing the UDF written by me:

public void getProperTime(String[] time,ResultList result,Container container){

String strDestTime = " ";

String strTempTime = " ";

String strTempTime1 = " ";

int intTime = 0;

if (time!=null)

{

strTempTime = time[0].substring(1,3);

strTempTime1 = time[0].substring(3);

intTime = Integer.parseInt(strTempTime);

}

if(intTime<12)

{

if (intTime<10)

{

strTempTime = "0"+intTime;

}

else

{

strTempTime = ""+intTime;

}

strDestTime = strTempTime + strTempTime1 +"AM";

}

else

{

intTime =intTime - 12;

if (intTime<10)

{

strTempTime = "0"+intTime;

}

else

{

strTempTime = ""+intTime;

}

strDestTime = strTempTime + strTempTime1 +"PM";

}

result.addValue(strDestTime);

}

Prabhu and Chaku: Can u tell me what changes have to be made in the properties of the current date?

Regards,

Divija.

Former Member
0 Kudos

Hi Divija,

happy you solved your problem.

Have you been able to solve it using <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html">SimpleDateFormat</a> patterns (hh:mm a) or did you find another solution?

Kind Regards,

Sergio

PS: Don't forget to close this thread if you consider the problem solved

prabhu_s2
Active Contributor
0 Kudos

You can use the date transformation in mapping program where you can set the properties on how the target value shoud appear.

Former Member
0 Kudos

Yes it is possible without an UDF. You need to do the setting in the node DATE TRANSFORMATION of the graphical mapping.

Former Member
0 Kudos

Dear Divija,

U can do it..

Just create one time field in target structure andd assign the time in mapping to that filed and use it in receiver adapter.

Venu.

Former Member
0 Kudos

Hi Divija,

yes, you can do it using Current Date and specifing <b>hh:mm a</b> as the format.

You can use this format as well with DateTrans block if you need to translate a date and not to get a timestamp.

Have a look at this java doc, it could help: <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html">Class SimpleDateFormat</a>

Hope this solve your problem

Kind Regards,

Sergio

Former Member
0 Kudos

Hi Divija,

You have no other option for this except going for UDF.

Also going for UDF would reduce the complexity too.

Regards

Madhu

former_member189558
Contributor
0 Kudos

Divija,

I think you need to go for an UDF only....

Cheers,

Himadri