This is a Xamarin Forms app.
In some part of the code, I am transfering an object to a Web Api 2 service.
The object is serialized using this:
var json = JsonConvert.SerializeObject(new
{
item.Codigo,
registro.Fecha,
Latitud = registro.Posicion.Latitude,
Longitud = registro.Posicion.Longitude,
Altitud = registro.Posicion.Altitude
});
Where registro.Fecha contains a date and time.
If that variable is, for example, 25th July 2019 at 07:02 P.M.
The date and time is serialized this way:
2019-07-25T19:02:09.53052+08:00
How can I get rid of that "+08:00"? That causes the Web Api application store the data as 25th July 2019 at 07:02 A.M.. My country is at UTC-4. I think that is why the server store the data with +12 hours in difference.
When using a REST tester, I pass the parameter without the "+08:00" and it works.
How can I solve this?
I tried by adding
var userSelectedCulture = new System.Globalization.CultureInfo("es-CL");
System.Threading.Thread.CurrentThread.CurrentCulture = userSelectedCulture;
in MainActivity OnCreate method but it did not work.
Regards Jaime