cancel
Showing results for 
Search instead for 
Did you mean: 

Getting wrong SourceFileTimestamp from DynamicConfiguration

Former Member
0 Kudos

In order to get the timestamp for a file we built the following user defined function within a message mapping:

public String GetFileTimeStampt(Container container){

DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

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

String ourSourceFileName = conf.get(key);

return ourSourceFileName;

}

The value returned is the UTC-0 time instead the UTC-3 time corresponding to our time zone (Buenos Aires).

Does anybody knows how to setup what in order to get our UTC-3 time rather than the GMT time?

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

It seems that everything in XI runs under no UTC setting.

Nevertheless you can use the following code in order to adjust your file timestamp.

// Please include the following imports

// import java.util.*;

// import java.text.*;

DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","ourSourceTimeStamp");

String ourSourceTimeStamp = conf.get(key);

// example value obtained = "20060101T000203Z"

int iUTC = -3; // our UTC for Buenos Aires

int iYear = Integer.parseInt(ourSourceTimeStamp.substring(0,4));

int iMonth = Integer.parseInt(ourSourceTimeStamp.substring(4,6));

int iDay = Integer.parseInt(ourSourceTimeStamp.substring(6,8));

int iHour = Integer.parseInt(ourSourceTimeStamp.substring(9,11));

int iMin = Integer.parseInt(ourSourceTimeStamp.substring(11,13));

int iSec = Integer.parseInt(ourSourceTimeStamp.substring(13,15));

GregorianCalendar sTimeStamp = new GregorianCalendar(iYear,iMonth-1,iDay,iHour,iMin,iSec);

sTimeStamp.add(Calendar.HOUR_OF_DAY,iUTC);

iYear = sTimeStamp.get(Calendar.YEAR);

iMonth = sTimeStamp.get(Calendar.MONTH)+1;

iDay = sTimeStamp.get(Calendar.DAY_OF_MONTH);

iHour = sTimeStamp.get(Calendar.HOUR_OF_DAY);

iMin = sTimeStamp.get(Calendar.MINUTE);

iSec = sTimeStamp.get(Calendar.SECOND);

NumberFormat formatter = NumberFormat.getNumberInstance();

formatter.setMinimumIntegerDigits(4);

formatter.setGroupingUsed(false);

String sYear = formatter.format(iYear);

formatter.setMinimumIntegerDigits(2);

String sMonth = formatter.format(iMonth);

String sDay = formatter.format(iDay);

String sHour = formatter.format(iHour);

String sMin = formatter.format(iMin);

String sSec = formatter.format(iSec);

ourSourceTimeStamp = sYearsMonthsDay'T'sHoursMinsSec+'Z';

return ourSourceTimeStamp;

// result value after conversion = "20051231T210203Z"

Message was edited by:

Gustavo Oga

Former Member
0 Kudos

Hi everybody

First an errata: in the piece of code which where theft from a example, where says "ourSourceFileName" should say "ourFileTimeStamp" or other more accordingly denomination of such a variable.

Second: according to the output of SXMB_MONI the user is XIAFUSER which Personal Time Zone is UTC-3

Anyway i realize that we can extend our java code to subtract 3 from the hour and reconstruct the string.

I will try that and, in case of success, publish the solution.

Former Member
0 Kudos

Gustavo

Did you ever run STZAC transaction on your system ?

Regards

Shravan

Former Member
0 Kudos

Hi,

Check on this thread:

Regards

Vijaya