- A
Date
is a point in time, it doesn’t have a format nor a time zone. print
shows the description – a string representation – of the date in the UTC time zone.- Your time zone is obviously UTC +0900,
2020-04-12 00:00:00 +0900
and2020-04-11 15:00:00 +0000
is the same point in time. -
If you want to create the date string independent of the time zone add the line
dateFormatIn.timeZone = TimeZone(secondsFromGMT: 0)
5
solved how to convert a String to a Date without changing the Format