Sunday, March 15, 2009

issue with Xp20:Current-Datetime function during Daylight saving


There is a issue in using Xp20:Current-Datetime function. The function will return you the current time, but during day light saving period it will return you the time 1hour ahead of current time.

So need to be careful while using this function. We were using the time to store as the last run time and it always gave 1 hour ahead of current time. For example format of current-DateTime function is like 2009-03-12T21:46:22-08:00. ‘-08:00’ char which used to cause all the issues.

This is the work around mentioned in METALINK to get the correct datetime value.

Step 1: Create two variables in the BPEL process

<variable name="curDatetime" type="xsd:string"/>
<variable name="curDT" type="xsd:dateTime"/>

Step 2; Create an Assign activity and two copy rules as follows,
<assign name="AssignCurrentDateTime">
<from expression="xp20:current-dateTime()"/>
<to variable="curDatetime"/>
<from expression="concat(ora:formatDate(bpws:getVariableData('curDatetime'), 'yyyy-MM-dd'), 'T', ora:formatDate(bpws:getVariableData('curDatetime'),'HH:mm:ss'),substring(string(ora:formatDate(bpws:getVariableData('curDatetime'), 'Z')),1,3),':',substring(string(ora:formatDate(bpws:getVariableData('curDatetime'), 'Z')),4))"/>
<to variable="curDT"/>

The CurDT variable should have the correct datatime value.

1 comment:

Anonymous said...


I was looking to your issue's solution and wondering if there's a way besides the hard-coded one. Something like a function that converts the current-datetime() to a specific format.