Converting a SQLDateTime string to Date always converts to UTC [Swift]

// convert SQLDate String to Date
func SQLDateTimeToDate(_ sqldate : String) -> Date {
    var sDate : String = Trim(sqldate)
    if sDate.count==10 { sDate="\(sDate) 00:00:00" }
    dateFormatter.dateFormat = SQLDateFormat // "yyyy-MM-dd HH:mm:ss"
    //  dateFormatter.locale     = Locale.current
    print("S=\(sDate)") // 2022-10-18 23:59:59
    return dateFormatter.date(from: sDate)! // -> 2022-10-19 06:59:59 // this is UTC?!
}

This driving me CRAZY… setting Locale or not makes no difference
it ALWAYS adds the UTC TZ offset which of me is 7 hours right now

Not sure why I had to do this, but it seems to work

// convert SQLDate String to Date
func SQLDateTimeToDate(_ sqldate : String) -> Date {
    var sDate : String = Trim(sqldate)
    if sDate.count==10 { sDate="\(sDate) 00:00:00" }
    dateFormatter.dateFormat = SQLDateFormat
    return local_Date(dateFormatter.date(from: sDate)!) 
}

func local_Date(_ d : Date) -> Date {
    let timeZoneOffset = Double(TimeZone.current.secondsFromGMT(for: d))
    let localDate      = Calendar.current.date(byAdding: .second, value: Int(timeZoneOffset), to: d)!
    return localDate
}

dateFormatter has an attribute .timeZone. Documentation says ‘ If unspecified, the system time zone is used.’.
https://developer.apple.com/documentation/foundation/dateformatter/1411406-timezone

Haven’t tested, I am not in front of my computer.

well that did not seem to be the case :frowning:
since I did not specify one

This seems to work:

which is NOT using the system timezone