Article
Problem
A Forum reader recently asked:
"I'm trying to parse a string in a format "d.M.y" (like 23.12.2007) for Login Expiration Time. Any ideas?"
And here's the response from Dave Gersic ...
Solution
If you know it'll always be in that format, you can just break it up with substring.
I have this policy on one of my DelimText drivers to allow specified Login Expiration Time in human format:
<?xml version="1.0" encoding="UTF-8"?><policy
xmlns:jdate="http://www.novell.com/nxsl/java/java.util.Date"
xmlns:jdateformat="http://www.novell.com/nxsl/java/java.text.SimpleDateFormat">
<rule>
<description>Expire Accounts - Specified Date</description>
<conditions>
<and>
<if-operation mode="case" op="equal">add</if-operation>
<if-op-attr name="Login Expiration Time" op="available"/>
</and>
</conditions>
<actions>
<do-set-local-variable name="ExpireDate">
<arg-string>
<token-substring length="2" start="4">
<token-op-attr name="Login Expiration Time"/>
</token-substring>
<token-text xml:space="preserve">/</token-text>
<token-substring length="2" start="6">
<token-op-attr name="Login Expiration Time"/>
</token-substring>
<token-text xml:space="preserve">/</token-text>
<token-substring length="4" start="0">
<token-op-attr name="Login Expiration Time"/>
</token-substring>
</arg-string>
</do-set-local-variable>
<do-reformat-op-attr name="Login Expiration Time">
<arg-value type="time">
<token-xpath expression="round(jdate:parse($ExpireDate)div 1000)"/>
</arg-value>
</do-reformat-op-attr>
<do-break/>
</actions>
</rule>
<rule>
<description>Expire Accounts - Default 1 Year</description>
<conditions>
<and>
<if-operation mode="case" op="equal">add</if-operation>
<if-op-attr name="Login Expiration Time" op="not-available"/>
</and>
</conditions>
<actions>
<do-set-dest-attr-value name="Login Expiration Time">
<arg-value type="string">
<token-xpath expression="round(jdate:getTime(jdate:new()) div
1000)+31536000"/>
</arg-value>
</do-set-dest-attr-value>
<do-break/>
</actions>
</rule>
</policy>
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
Another option
Submitted by bstumpp on 2 January 2008 - 10:51am.
I am not completely sure what you are trying to do, but another option would be to use the "Convert Time" verb. It is a new verb in IDM 3.5 and will allow you to convert time from one format to another. Such as from number of milliseconds since January 1, 1970 to a Month/Day/Year format.
- Be the first to comment! To leave a comment you need to Login or Register
Time token
Submitted by geoffc on 2 January 2008 - 1:53pm.
I am pretty sure the example given by David G. is specifically for a user WITHOUT access to IDM 3.5.x. This is how you do it the old way.
For a link to the 'new' way, check:
http://www.novell.com/communities/node/2572/using-...
And yes, the new time tokens are WAY easier than Java time.
- Be the first to comment! To leave a comment you need to Login or Register


2