Date conversion in xforms
I have following data instance which has date node (transaction-date) bound to a date picker (input).
By default its storing the date in CCYY-MM-DD format. I would like to have another node (temp-transaction-date) which will be updated in MMM/DD/CCYY format in xforms-value-changed event.
<xform开发者_JAVA技巧s:instance id="form-instance">
<attributes>
<transaction-date></transaction-date>
<temp-transaction-date></temp-transaction-date>
</attributes>
</xforms:instance>
<xforms:bind id="transaction-date" nodeset="instance('form-instance')/transaction-date" type="xforms:date" />
<td>
<xforms:input bind="transaction-date">
<xforms:action ev:event="xforms-value-changed">
<xforms:setvalue ref="instance('form-instance')/temp-transaction-date" value="?"/>
</xforms:action>
</xforms:input>
</td>
Please let me know how can i set the value in the format of Mar/09/2011 or is there an alternate way to achieve the same.
You can do this with an <xforms:bind calculate="…">
and the function format-date()
:
<xforms:bind nodeset="temp-transaction-date"
calculate="format-date(../transaction-date), '[MNn,*-3]/[D01]/[Y]')"/>
精彩评论