Search code examples
datetime-formatwebmethods

Date format for timestamp in WebMethods


I am trying to create Event Timestamp as per the below format:- 2021-04-05T06:39:33.931-07:00

I tried using the below pattern for the same: yyyy-MM-dd'T'HH:mm:ss.SSSZZZZ

Unfortunately, the output is not the same. Below is the output for the same: enter image description here

Can you please suggest what should be the correct pattern for this? Below is the code block where I am putting the inputs:- enter image description here


Solution

  • Pattern for a time zone with a colon: yyyy-MM-dd'T'HH:mm:ss.SSSXXX

    WebMethods pub.date:getCurrentDateString uses java.text.SimpleDateFormat.

    From the Java 1.8 Date and Time Patterns (adapted to fit the question):

    Letter Date or Time Component Presentation Example
    X Time zone ISO 8601 time zone -07
    XX Time zone ISO 8601 time zone -0700
    XXX Time zone ISO 8601 time zone -07:00