6 Replies Latest reply on Feb 13, 2013 5:33 AM by Sen2008

    DateTime with Timezone in XSLT

    Sen2008
      All,

      version: 11.1.1.4
      I have a requirement where in I have to validate the datetime in XSLT. User A will send a xml doc with a dateformat he is comfortable. like this many users will send a similar xml doc to my application which can have datetime in any format. But my application wants in a particular format i.e '2013-01-20T05:11:42+05:30'. In XSLT I want to check if the dateformat in the xml doc is in the expected format, send the doc as it is, otherwise format it to the expected date. I'm exploring xp20:format-dateTime function to achieve this.

      to put it in simple algorithm

      if dateformatin xml doc = 'format expected' then
      send as it is
      else
      format it to expected date

      I tried using the xp20:format-dateTime function as <xsl:value-of select="xp20:format-dateTime(/ns0:cXML/Request/InvoiceDetailRequest/InvoiceDetailRequestHeader/@invoiceDate,'[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01]')"/> but don't know how to add the timezone to it. Any help is appreciated.

      thanks
      sen
        • 1. Re: DateTime with Timezone in XSLT
          mathieu.d
          Hi,

          This link might help you (try [z]) :
          http://www.sugihartono.com/programming/bpel-format-date-time-reference-and-example/

          But I'm not sure it will generate the exact output you want.

          regards,
          mathieu
          1 person found this helpful
          • 2. Re: DateTime with Timezone in XSLT
            vladodias
            many users will send a similar xml doc to my application which can have datetime in any format
            Just be aware that receiving datetime in any format as you stated is not quite achievable... If you receive 01-12-2013, will be that the 12th of Jan or the 1st of Dec? At the end of the day you will have to decide what format (or formats) you will accept...

            Also xp20:format-dateTime won't help you in this matter, this functions gets a ISO8601 date and formats it... I believe you're trying to do the reverse, and there's no function available in BPEL to do it... Either you'll have to write a custom function or use a java callout with SimpleDateFormat...

            Cheers,
            Vlad
            • 3. Re: DateTime with Timezone in XSLT
              Sen2008
              Thanks for clarifying. Atleast I want to know if the user sends with mm/dd/yyyy format, using xp20:format-dateTime function should I be able to convert it into mm-dd-yyyy format?? Pls

              rgds
              sen
              • 4. Re: DateTime with Timezone in XSLT
                mathieu.d
                Hi,

                As stated above, the function xp20:format-dateTime is used to convert a "string" into an "XML dateTime". There is no function to do the reverse (surprisingly).
                I searched a little and people often use either a java code or an SQL request to do the convertion.

                regards,
                mathieu
                • 5. Re: DateTime with Timezone in XSLT
                  vladodias
                  Sen2008 wrote:
                  if the user sends with mm/dd/yyyy format, using xp20:format-dateTime function should I be able to convert it into mm-dd-yyyy format?? Pls
                  No, xp20:format-dateTime gets a XML date (ISO8601) and converts it to a formatted string... Not the reverse...

                  This page explains what ISO8601 is...
                  http://docstore.mik.ua/orelly/xml/schema/ch04_05.htm

                  Cheers,
                  Vlad
                  • 6. Re: DateTime with Timezone in XSLT
                    Sen2008
                    thanks everyone for the pointers.

                    sen