cancel
Showing results for 
Search instead for 
Did you mean: 

Read date and timestamp of XI message with milliseconds

Former Member
0 Kudos

Hi,

Any suggestions on how read the date and timestamp of XI message with milliseconds as I was able to read only till second only.

But I want to capture milliseconds of the message also.

The standard Date function(CurrentDate)  capable of reading till Sec only, not supporting for MilliSeconds.

The format that XI capable of : dd/MM/yyyy HH/mm/ss

Expecting Format : dd/MM/yyyy HH/mm/ss/SSS.

Appreciate Your Quick Respose......

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi,

try this for getting the milliseconds.

Former Member
0 Kudos

Praveen,

It can be achieved with the standard currenDate function available.

For Example give the format as yyyyMMddHHmmssSSS.

Former Member
0 Kudos

In the helps above, you'll get the "Mapping" Timestamp, and not the Message's Timestamp.

To get the Message's TimeStamp, you can use the follow code:

try {

String timestamp = "";

DynamicConfiguration conf1 = (DynamicConfiguration) container

     .getTransformationParameters()

     .get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey key1 = DynamicConfigurationKey.create( "http:/"+"/sap.com/xi/XI/System/File","SourceFileTimestamp");

timestamp = conf1.get(key2);

return timestamp;

}

catch(Exception e)

{

     String exception = e.toString();

      return exception;

}

In Communication Channel, Click on Advanced tab and check the Option “SetAdapterSpecificMessageAttributes” in addition to that check the attribute that are required to be captured during run time. In our case Source File Time Stamp are required to be checked.

baskar_gopalakrishnan2
Active Contributor
0 Kudos

Simone,

You have referenced key2 variable ... This seems typo...

timestamp = conf1.get(key1);

Former Member
0 Kudos

Yes, sorry Baskar!

timestamp = conf1.get(key1);

You're right! A little mistake

Ryan-Crosby
Active Contributor
0 Kudos

Hi Praveen,

A simple UDF can accomplish this with the following java imports and code:

import java.util.date

import java.text.SimpleDateFormat;

SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH/mm/ss/SSS");

return sdf.format(new Date());

Regards,

Ryan Crosby

zameerf
Contributor
0 Kudos

Just try mentioning dd/MM/yyyy HH/mm/ss/SSS as the target format in 'Current Date' standard function in mapping.It should work.