ios - NSDateComponentsFormatter Units Separator -
i want convert time in minutes user friendly string. following code resolves issue, except 1 thing - want result 1 hr 30 min
, got 1 hr, 30 min
. how specify units separator nsdatecomponentsformatter? of course, can remove commas manually, isn't looks best way me.
nsdatecomponentsformatter *formatter = [[nsdatecomponentsformatter alloc] init]; formatter.allowedunits = nscalendarunitday | nscalendarunithour | nscalendarunitminute; formatter.unitsstyle = nsdatecomponentsformatterunitsstyleshort; nslog(@"%@", [formatter stringfromtimeinterval:90*60]);
if application targeting os x 10.12 (or later, presume) or ios 10.10 (or later), apple added new units style called "nsdatecomponentsformatterunitsstylebrief"
formatter.unitsstyle = nsdatecomponentsformatterunitsstylebrief
and print out "1 hr 30 min"
Comments
Post a Comment