Article

dgersic's picture
article
Reads:

3265

Score:
0
0
 
Comments:

0

Retrieving Date/Time Text Strings via Java

Author Info

30 May 2007 - 1:51am
Submitted by: dgersic

(View Disclaimer)

Problem

A Forum reader recently asked:

"I'm no java programmer, and I could use a hand. I'm looking for a simple xpath call to Java that retrieves the Date/Time in a text string, including any arrangement of Month, Day, Year, Hours, Minutes and Seconds. Namespace reference would be useful, too."

And here's the response from David Gersic ...

Solution

Try this:

<?xml version="1.0" encoding="UTF-8"?>
<policy
 xmlns:jdate="http://www.novell.com/nxsl/java/java.util.Date"

xmlns:jformat="http://www.novell.com/nxsl/java/java.text.SimpleDateFormat">
 <rule>
  <description>Put object create date info to Description
attribute</description>
  <conditions>
   <and>
    <if-class-name op="equal">User</if-class-name>
   </and>
  </conditions>
  <actions>
   <do-set-dest-attr-value name="Description">
    <arg-value type="string">
     <token-text xml:space="preserve"
xmlns:xml="http://www.w3.org/XML/1998/namespace">Account created:
</token-text>
     <token-xpath expression="jformat:format(jformat:new('MM/dd/yyyy
HH:mm:ss'),jdate:new())"/>
    </arg-value>
   </do-set-dest-attr-value>
  </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.




User Comments

© 2013 Novell