How to show the Netherlands time in hours (uur) in Dutch?

147 Views Asked by At

Show time for multiple countries with native time format.

Trying to Display time of Netherland eg: 22.37 uur

With Locale: nl_NL

For Date: 2019-09-17 17:07:00 +0000

I have tried the code below:

let formatter = DateComponentsFormatter()
var calendar = Calendar.gregorianCalendar()
calendar.locale = apiDate.locale // nl_NL
formatter.calendar = calendar
formatter.unitsStyle = .short
formatter.allowedUnits = [.hour, .minute]
formatter.zeroFormattingBehavior = [.dropLeading, .pad]
let dateComponent = calendar.dateComponents([.hour, .minute], from: apiDate.absoluteDate) //apiDate.absoluteDate: Date : 2019-09-17 17:07:00 +0000
print(formatter.string(from: dateComponent) as Any) // prints 22 uur, 37 min

Expected: 22.37 uur

Actual: 22 uur, 37 min

0

There are 0 best solutions below