I have a REST service which returns date in milliseconds format <birthdate>628453800000</birthdate> How can I convert it to mm/dd/yyyy and display it in date control. Thanks, Vinod S You received this message because you are subscribed to the Google Groups "Orbeon Forms" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. |
Administrator
|
Hi Vinod,
Assuming the value you have is a number of milliseconds since 1970, for positive values (i.e. birthdates after 1970), you can use the following, replacing 628453800000 by a reference to the variable or node with the value: xs:dateTime("1970-01-01T00:00:00-00:00") + xs:dayTimeDuration(concat('PT', 628453800000 div 1000, 'S')) And if you need to handle dates before 1970, I'll leave you the handling of negative values as an exercise ;). Alex
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
xs:dateTime("1970-01-01T00:00:00-00:00") + xs:dayTimeDuration(concat('PT',
628453800000 div 1000, 'S')) I want to use the above expression in Actions editor window as a source xpath expression for a date control. The value 628453800000 needs to be accessed from the xml returned by REST call using xpath, How to do it inside above expression? Can I evaluate xpath inside xs:dayTimeDuration? Thanks, Vinod S -----Original Message----- From: [hidden email] [mailto:[hidden email]] On Behalf Of Alessandro Vernet Sent: Thursday, July 16, 2015 12:37 AM To: [hidden email] Subject: [orbeon] Re: How to convert date from milliseconds to mm/dd/yyyy Hi Vinod, Assuming the value you have is a number of milliseconds since 1970, for positive values (i.e. birthdates after 1970), you can use the following, replacing 628453800000 by a reference to the variable or node with the value: xs:dateTime("1970-01-01T00:00:00-00:00") + xs:dayTimeDuration(concat('PT', 628453800000 div 1000, 'S')) And if you need to handle dates before 1970, I'll leave you the handling of negative values as an exercise ;). Alex ----- -- Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet -- View this message in context: https://urldefense.proofpoint.com/v2/url?u=http-3A__discuss.orbeon.com_How-2Dto-2Dconvert-2Ddate-2Dfrom-2Dmilliseconds-2Dto-2Dmm-2Ddd-2Dyyyy-2Dtp4660247p4660250.html&d=AwIBaQ&c=IV_clAzoPDE253xZdHuilRgztyh_RiV3wUrLrDQYWSI&r=S6ZjXQDCefSKNBSveJ2jCOEEuW_KAGvrphcELo2RNCI&m=1bIwts8CPrHwvyu9T_ggDdrFUeoZa8Xr5HXt13vZ6dg&s=5whZNaEZks4PgeyKnrHAWyUc2Wel3BI4sl2g0AShbPY&e= Sent from the Orbeon Forms community mailing list mailing list archive at Nabble.com. -- You received this message because you are subscribed to the Google Groups "Orbeon Forms" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. -- You received this message because you are subscribed to the Google Groups "Orbeon Forms" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. |
Administrator
|
Hi Vinod,
Yes, definitely: instead of 628453800000, you can have another expression like /root/person/birthdate, making a reference to the birthdate returned in the response to your service call. Alex
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
xs:dateTime("1970-01-01T00:00:00-00:00") + xs:dayTimeDuration(concat('PT', /root/caseinfo[1]/patient/birthdate div 1000, 'S'))
I am using the xpath /root/caseinfo[1]/patient/birthdate in above expression its throwing up an error while preview/test. Error log is attached to this mail. Instead of xpath /root/caseinfo[1]/patient/birthdate, if I use 628453800000 value its working fine. But I want to use the xpath to extract it from rest call. Thanks, Vinod S -----Original Message----- From: [hidden email] [mailto:[hidden email]] On Behalf Of Alessandro Vernet Sent: Friday, July 17, 2015 3:20 AM To: [hidden email] Subject: [orbeon] Re: How to convert date from milliseconds to mm/dd/yyyy Hi Vinod, Yes, definitely: instead of 628453800000, you can have another expression like /root/person/birthdate, making a reference to the birthdate returned in the response to your service call. Alex ----- -- Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet -- View this message in context: https://urldefense.proofpoint.com/v2/url?u=http-3A__discuss.orbeon.com_How-2Dto-2Dconvert-2Ddate-2Dfrom-2Dmilliseconds-2Dto-2Dmm-2Ddd-2Dyyyy-2Dtp4660247p4660257.html&d=AwIBaQ&c=IV_clAzoPDE253xZdHuilRgztyh_RiV3wUrLrDQYWSI&r=S6ZjXQDCefSKNBSveJ2jCOEEuW_KAGvrphcELo2RNCI&m=lWOW2uhKp0Zo_C7NokV0t8VcR8ECfZDMjPfYl1lJZqQ&s=kCBjyAAFjoRmqA9DorMtIv9SYDw24JwVP0hEMm7bsQc&e= Sent from the Orbeon Forms community mailing list mailing list archive at Nabble.com. -- You received this message because you are subscribed to the Google Groups "Orbeon Forms" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. -- You received this message because you are subscribed to the Google Groups "Orbeon Forms" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. errorLog.txt (172K) Download Attachment |
Administrator
|
Hi Vinod,
This is most likely because you need to cast the node to number type, e.g. with xs:integer(/root/caseinfo[1]/patient/birthdate). I should have mentioned this in my earlier message! Alex
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
Free forum by Nabble | Edit this page |