Webservice Lose hours in data

Webservice Lose hours in data

  
Hi All,

I have a little problem, I have a webservice in Spain and I consume that webservice in Portugal, the webservice send me a field DataTime that when arrives in Portugal that data lost 1h due time zone changes.

Any ideia how I fixe that ?
Changed the time zone in server doesn't count :)

Best regards,
Frederico Fernandes
Hi Frederico,
I don't think that you have here a lost or something to fix..
Since the Time Zone is different, you have to implement your own code to use that date times as you want, since the WS for you is a black box where you input something to get/do something.

Best Regards,
Gonçalo M.
Actually, the webservice in Spain should provide you with a DateTime you can handle properly.
Either in UTC or written like "HH:MM:SS+1" so you know how to correct it.

Beware of summertime if you create your own fix.

I'm curious btw, when you call the webservice in SoapUI for example, what is the result on that datetime then?
That's right..
The Service is blind against this kind of issues.
If it's not owned by you and you just consume it, you have to do your own business logic and handle the right "fixes" with all the rules related to TimeZone issues.

 Best Regards,
Gonçalo M.
Kind
 
Hi,

Statler & Waldorf when I call in Storm for example it returns the time -1h (Time in Spain).

The web service is mine, How can i change the datetime field to UTC, is there a property in webservice or I have to take care of it when i send the response? 
Hi Frederico,

Since the WebService is yours and assuming that you use .NET (in this case 4.5) you can take a look at this C# class - TimeZoneInfo -, and the following method to convert datetimes between TimeZones:

http://msdn.microsoft.com/en-us/library/bb382770.aspx

Let me know if it helps.

Kind Regards,
Gonçalo M.
Hi Frederico,

Since the WebService is yours and assuming that you use .NET (in this case 4.5) you can take a look at this C# class - TimeZoneInfo -, and the following method to convert datetimes between TimeZones:

http://msdn.microsoft.com/en-us/library/bb382770.aspx

Let me know if it helps.

Kind Regards,
Gonçalo M.
Ok thanks I think that link help :)
Just to add more info:

In your version is previous the .NET 4.5, you can use the  TimeZoneInfo.ConvertTimeBySystemTimeZoneId in .NET 3.5 and 4.0, that converts a time to the time in another time zone, based on a time zone identifier.
Here’s how to use this method using different time zone identifiers like “GMT Standard Time”, using just a simple code snippet:

static void Main(string[] args)
{
    DateTime dt = DateTime.Now;
    Console.WriteLine("Time in Different TimeZones:\n");

    Console.WriteLine("Greenwich Mean Time (GMT): {0}",
                TimeZoneInfo.ConvertTimeBySystemTimeZoneId(dt,
                TimeZoneInfo.Local.Id, "GMT Standard Time"));
    Console.ReadLine();
}


With this method you can do you conversion in the moment you send the date time using the WS method.

Kind Regards,
GM
Frederico Fernandes wrote:
Ok thanks I think that link help :)
Hope so :)
Let me know about the result and share it if you can..


 
Real cool  information.
Good to know this if I have this kind of problems..
Can you tell it worked, Gonçalo?


Hi!!
I'm waiting for a reply from Frederico to check if it works and how he implemted the WebService.

Regards,
GM
@Frederico Fernandes

You could use the code provided by Gonçalo Martins

Or you can use Geo component Timezone_ConvertTimezoneByCode action.

You can download Geo component from here. http://www.outsystems.com/forge/265/geo-look-up-tables/



Gonçalo Martins wrote:
Just to add more info:

In your version is previous the .NET 4.5, you can use the  TimeZoneInfo.ConvertTimeBySystemTimeZoneId in .NET 3.5 and 4.0, that converts a time to the time in another time zone, based on a time zone identifier.
Here’s how to use this method using different time zone identifiers like “GMT Standard Time”, using just a simple code snippet:

static void Main(string[] args)
{
    DateTime dt = DateTime.Now;
    Console.WriteLine("Time in Different TimeZones:\n");

    Console.WriteLine("Greenwich Mean Time (GMT): {0}",
                TimeZoneInfo.ConvertTimeBySystemTimeZoneId(dt,
                TimeZoneInfo.Local.Id, "GMT Standard Time"));
    Console.ReadLine();
}


With this method you can do you conversion in the moment you send the date time using the WS method.

Kind Regards,
GM
 
 
You're right, Robert..
I gave this example because I don't know if the WebService is implemented in Outsystems or if it's a C# .Net Webservice..But is also a good tip.

Kind Regards,
GM




Robert Chanphakeo wrote:
@Frederico Fernandes

You could use the code provided by Gonçalo Martins

Or you can use Geo component Timezone_ConvertTimezoneByCode action.

You can download Geo component from here. http://www.outsystems.com/forge/265/geo-look-up-tables/



Gonçalo Martins wrote:
Just to add more info:

In your version is previous the .NET 4.5, you can use the  TimeZoneInfo.ConvertTimeBySystemTimeZoneId in .NET 3.5 and 4.0, that converts a time to the time in another time zone, based on a time zone identifier.
Here’s how to use this method using different time zone identifiers like “GMT Standard Time”, using just a simple code snippet:

static void Main(string[] args)
{
    DateTime dt = DateTime.Now;
    Console.WriteLine("Time in Different TimeZones:\n");

    Console.WriteLine("Greenwich Mean Time (GMT): {0}",
                TimeZoneInfo.ConvertTimeBySystemTimeZoneId(dt,
                TimeZoneInfo.Local.Id, "GMT Standard Time"));
    Console.ReadLine();
}


With this method you can do you conversion in the moment you send the date time using the WS method.

Kind Regards,
GM