IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.


#TechXchangePresenter
 View Only
Expand all | Collapse all

DateTime issue in webmethods

webMethods Community Member

webMethods Community MemberMon June 30, 2008 06:40 PM

webMethods Community Member

webMethods Community MemberWed October 17, 2012 03:50 PM

  • 1.  DateTime issue in webmethods

    Posted Sat June 28, 2008 04:50 AM

    I am invoking a webservice whic has field EndTime defined as DateTime data type in the xsd. But When I created the webservice connector, the document that got created for the request has EndTime as a string.

    ns1:createComparisonProductMovement

    When I parse the datetime into string and invoke the webservice with that, the webservice treats it in a strange manner and does not store the right date.

    Is there a problem with the webservice or the way I am invoking it?

    Can you please help?

    Thanks


    #soa
    #API-Management
    #webMethods


  • 2.  RE: DateTime issue in webmethods

    Posted Sat June 28, 2008 04:14 PM

    What date format are you using? XML dateTimes are in the format yyyy-MM-ddThh:mm:ss.SSSZ. The “T” is a literal capital letter “T”. The Z can either be a literal “Z” if UTC timezone is desired or can be an timezone offset from UTC in hours and minutes. Refer to the XML schema data types documentation for more details.

    Mark


    #soa
    #API-Management
    #webMethods


  • 3.  RE: DateTime issue in webmethods

    Posted Mon June 30, 2008 04:05 PM

    Thanks Mark!

    But I am using pub.date.dateTimeFormat to convert input datetime to another format to pass to the webservice

    and if I put in format yyyy-MM-ddThh:mm:ss.SSSZ, I get an exception back.


    #webMethods
    #soa
    #API-Management


  • 4.  RE: DateTime issue in webmethods

    Posted Mon June 30, 2008 05:19 PM

    Enclose the “T” and “Z” in single quotes as specified in the documentation for this built-in service.

    Mark


    #soa
    #webMethods
    #API-Management


  • 5.  RE: DateTime issue in webmethods

    Posted Mon June 30, 2008 06:40 PM

    Thanks Mark! That did it.


    #API-Management
    #soa
    #webMethods


  • 6.  RE: DateTime issue in webmethods

    Posted Wed October 10, 2012 12:28 PM

    Hi Mark,
    With the help of this post i formed correct datetime format…Now i want to change this datetime format to UTC format…How to solve this…Can you please help me onthis issuse.


    #API-Management
    #webMethods
    #soa


  • 7.  RE: DateTime issue in webmethods

    Posted Fri October 12, 2012 02:01 AM

    There isn’t a UTC “format” per se. Are you looking to convert a time to UTC/GMT time?


    #API-Management
    #soa
    #webMethods


  • 8.  RE: DateTime issue in webmethods

    Posted Sun October 14, 2012 08:38 AM

    Hi Raemon,
    Thanks for ur reply…I am trying to develope service…say for example client send his own format like yyyy-MM-dd’T’HH:mm:ss ex:2012-10-08T11:47:33(JST)…now i want to convert this time to UTC format by using webMethods built in services…can you please help me on this issuse.


    #API-Management
    #soa
    #webMethods


  • 9.  RE: DateTime issue in webmethods

    Posted Mon October 15, 2012 04:46 AM

    You didn’t answer my question. There is no such thing as “UTC format.” Are you trying to convert the time you provided to the UTC/GMT timezone?


    #webMethods
    #API-Management
    #soa


  • 10.  RE: DateTime issue in webmethods

    Posted Mon October 15, 2012 10:49 AM

    HI Raemon,
    Sorry for the confusion…Yes i am looking to convert to UTC time zone.


    #soa
    #API-Management
    #webMethods


  • 11.  RE: DateTime issue in webmethods

    Posted Mon October 15, 2012 10:30 PM

    Here is one way:

    Parse the incoming string to a java.util.Date. You may need to write your own Java service that uses SimpleDateFormat to do the parsing.

    Pass the resulting Date object to pub.date:formatDate, specifying the appropriate inputs to get the timezone and format you want.

    There are other ways but this should work.


    #API-Management
    #webMethods
    #soa


  • 12.  RE: DateTime issue in webmethods

    Posted Tue October 16, 2012 04:50 PM

    Hi Reamon,
    By using your post in some other thread i created one java service.
    1)It is taking the string as date object and giving dateobject as string.
    2)By using this service I am able to convert My Jvm time format to any other format(UTC or IST…etc)…

    But i am looking for if client sends his own format(whatever it may be) but we should convert that into UTC time format. can you please help regarding this.


    #webMethods
    #API-Management
    #soa


  • 13.  RE: DateTime issue in webmethods

    Posted Tue October 16, 2012 06:29 PM

    I’ll try to explain a little bit differently.

    1. Create a service with these parameters:
      IN dateString - the string to be converted
      IN pattern - the pattern of the string in dateString
      OUT date - a java.util.Date object representing the value passed in dateString
      Logic: use SimpleDateFormat to parse the string and return the Date object

    2. Call pub.date:formatDate.
      IN date - pass the date object from the previous call
      IN pattern - specify the pattern string for the desire format. Based on what you’ve previously posted, this would be yyyy-MM-dd’T’hh:mm:ss.SSSZ
      IN timezone - omit this input; the default timezone is GMT
      IN locale - probably want to omit this unless you want to use another language
      OUT value - a string in the W3C format for the GMT/UT timezone

    You could combine these into a FLOW service if you want a single service to do both steps.

    For each partner, you’d call the service passing the format pattern that matches the string they are sending you.


    #webMethods
    #API-Management
    #soa


  • 14.  RE: DateTime issue in webmethods

    Posted Tue October 16, 2012 06:37 PM

    You need to create some custom logic to get GMT/UTC timezone from local…pl check the PSUtilities package there are some datetime utilities provided to play with.

    Also here is the sample java program that does converts to GMT time zone and similarly create a java service in wM

    HTH,
    RMG

    [url]http://javarevisited.blogspot.com/2012/04/how-to-convert-local-time-to-gmt-in.html[/url]


    #webMethods
    #soa
    #API-Management


  • 15.  RE: DateTime issue in webmethods

    Posted Tue October 16, 2012 07:48 PM

    What “custom logic” do you feel is needed?

    The formatDate service will do the proper conversion. No need to create custom code for timezone conversions.


    #soa
    #webMethods
    #API-Management


  • 16.  RE: DateTime issue in webmethods

    Posted Tue October 16, 2012 08:28 PM

    If it works for him that’s great out of box and if not alternate custom with util.date functions:

    Tested it and seems working for GMT from ET:


    #webMethods
    #API-Management
    #soa


  • 17.  RE: DateTime issue in webmethods

    Posted Wed October 17, 2012 02:10 PM

    Hi Raemon,
    Thanks for ur reply…it helped alot to me…
    i want to explain in a more clear way about what i need and what this service gave to me…
    As you told i developed a service…and it is working fine…
    in our flow there are two types flows 1)outbound 2)inbound
    1)outbound:- inthis flow we will send our date time to clients format[convert our jvm format(UTC) to Client needs(EST )…For this flow it working fine.
    2)Inbound :- in this flow we want to convert Client sended format(EST) to our format (UTC).For this flow above created service is not working…
    ex: client sends 2012-17-10 12:00:00 EST timezone(yyyy-dd-MM HH:mm:ss)…
    Input:I mapped time string and format to java service which i had as input…
    Output: it gave the date object as 2012-17-10 12:00:00 UTC.(but i am expecting 2012-17-10 7:00:00(EST means UTC+5))…it is frustating …Please can you clarify this.


    #soa
    #webMethods
    #API-Management


  • 18.  RE: DateTime issue in webmethods

    Posted Wed October 17, 2012 03:07 PM

    In the formatDate service did you gave the input timezone as GMT? and so it should output as GMT timezone (note you are in the US Eastern Day light savings mode UTC+4)…you can check here to make sure wM is outputing correctly or not for GMT/UTC

    [URL]http://wwp.greenwichmeantime.com/info/current-time[/URL]

    HTH,
    RMG


    #API-Management
    #soa
    #webMethods


  • 19.  RE: DateTime issue in webmethods

    Posted Wed October 17, 2012 03:50 PM

    Thank Reamon,
    Now it’s working perfectly…


    #API-Management
    #webMethods
    #soa


  • 20.  RE: DateTime issue in webmethods

    Posted Wed October 17, 2012 04:01 PM

    Glad it worked out as expected…BTW I am not Reamon :slight_smile:


    #API-Management
    #webMethods
    #soa