When sending data from Android (Kotlin client) is not transferred to the time zone:
ServiceStack:
JsConfig.DateHandler = DateHandler.ISO8601;
//POCO and data model
public class TestDataModel {
public DateTime Date { get; set; }
public string DateStringByTimeZone { get; set; }
public string TimeZone { get; set; }
}
col.InsertOne(new TestDataModel {
Date = request.Date,
DateStringByTimeZone = request.DateStringByTimeZone,
TimeZone = request.TimeZone,
});
Kotlin:
val date = Calendar.getInstance(TimeZone.getDefault()).time
val df = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ")
val request = TestDataModelRequest()
request.date = date
request.dateStringByTimeZone = df.format(date)
val client = AndroidServiceClient(host);
client.post(request)
result:
As you can see in the picture, changing the time zone on the client does not affect the date, the data on the client is correct, but when sending this data is lost.
When the date in the request is filled in as follows everything is processed correctly, so I assume the problem is in the client:
{ "Date": "2001-07-04T12:08:56+0300" }
I ask to prompt how correctly to transfer date, with time zone?
Thanks.