Article
Problem
A Forum reader recently asked:
"In the Password Notification Driver you developed, if I want the password expiration date to be displayed in a message in a time zone other than UTC, do I need to change any reference to UTC throughout the driver's code to another time zone? Or can I accomplish that by setting a date format using the java date definitions under the date/time format variable?"
And here's the response from Lothar Haeger ...
Solution
Assuming you use the latest version for IDM 351, date formatting is done in this for-each loop the a publisher event transform "#3 Reformat Values" with a convert-time token:
<token-convert-time dest-format="~DateTimeFormat~" src-format="yyyyMMddHHmmss'Z'" src-tz="UTC"> <token-xpath expression='$current-node/attr[@attr-name="passwordExpirationTime"]/value/text()'/> </token-convert-time>
This converts to the IDM server time zone and can be changed to any other time zone by adding a destination timezone:
<token-convert-time dest-format="~DateTimeFormat~" dest-tz="America/Boise" src-format="yyyyMMddHHmmss'Z'" src-tz="UTC"> <token-xpath expression='$current-node/attr[@attr-name="passwordExpirationTime"]/value/text()'/> </token-convert-time>
If you are still on IDM 3.0 or continue using an older driver config in IDM 3.51, you could hardcode a UTC offset into the xpath expression, which would be used instead of token-convert-time in that case:
<do-set-local-variable name="TimeZoneOffsetHours" scope="policy">
<arg-string>
<token-text xml:space="preserve">-6
</arg-string>
</do-set-local-variable>
<token-xpath expression='jformat:format(jformat:new("~DateTimeFormat~"), jdate:new($current-node/attr[@attr-name="Password Expiration Time"]/value * 1000 + $TimeZoneOffsetHours * 3600))'/>
You could also add a global variable to specify the time zone, if you declare the GCV like this:
<definition display-name="Timezone Offset (hours)" name="TimeZoneOffsetHours" range-hi="12" range-lo="-12" type="integer"> <description> <value>-6 </definition>
and refer to it as ~TimeZoneOffsetHours~ in the xpath - that should do just fine.
Disclaimer: As with everything else at Cool Solutions, this content is definitely not supported by Novell (so don't even think of calling Support if you try something and it blows up).
It was contributed by a community member and is published "as is." It seems to have worked for at least one person, and might work for you. But please be sure to test, test, test before you do anything drastic with it.
Related Articles
User Comments
- Be the first to comment! To leave a comment you need to Login or Register
- 5226 reads


0