Problem with DateFormatter for locale "Germany" and Swift 4 on Mac.

Hi all,

I have a simple question: I'm building an app for Mac with Swift, which needs to process an XML file and write the data into an SQLite DB.

This is a fragment of the XML record I need to process:


<Record type="myType" creationDate="2016-09-21 10:34:33 +0100" startDate="2016-09-21 10:34:33 +0100" endDate="2016-09-21 10:34:33 +0100" value="175"/>


My problem is to process the Date Time because I don't know how to properly pars the "+0100" in the datetime property. If I just remove it, when I read the data from the database I get back as example "2016-09-21 10:34:33 +0000" instead of "2016-09-21 10:34:33 +0100".


This is the fragment of Swift code that I use to encode the Date Time:


                let dateFormatter = DateFormatter()
                dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
                dateFormatter.locale = Locale(identifier: "de_DE")
                let creationDateAsDate = dateFormatter.date(from: "2016-09-21 12:56:33")
                let startDateAsDate = dateFormatter.date(from: "2016-09-21 11:07:59")
                let endDateAsDate = dateFormatter.date(from: "2016-09-21 11:14:02")


as you see I specify my local (German-Germany). I also tried to add the following:


dateFormatter.timeZone = NSTimeZone(abbreviation: "UTC") as TimeZone!


but with no effect.


Can you please suggest me how to fix this issue?


Thanks in advance for your help!
Gennaro