Sunday, 7 December 2014

Convert XML date and time to Tdatetime in Delphi



I am consuming a webservice/soap and loading XML tables for a clientdataset, I have a node with dates in this format:


2014-01-01T00:00:00.0000000-02:00


I am trying to convert this type of data for regional my type, I'm using this:



class function TDateConvert.DateTimeFromIso8601(const Value: string): TDateTime;
begin
with TXSDateTime.Create() do
try
XSToNative(value); // convert from WideString
Result := AsDateTime; // convert to TDateTime finally
finally
Free();
end;
end;


I'm getting, but the date is coming wrong, using that example above instead of returning 01/01/2014 31/12/2013 is returning, this is the date format used in Brazil (dd/MM/YYYY).


How can I solve this? It has to do with my regional settings (Brazil)?


No comments:

Post a Comment