DateTime issue in webmethods

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

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

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.

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

Mark

Thanks Mark! That did it.

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.

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

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.

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?

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

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.

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.

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.

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]

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.

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:

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.

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

Thank Reamon,
Now it’s working perfectly…

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