ios - NSDateFormatter cant parse German date -
i try make nsdateformatter
set locale german, fails. in code below, while datefrom
parsed, dateto
not.
note: in german februar, not february.
nslocale *germanlocale = [[nslocale alloc] initwithlocaleidentifier:@"de_de"]; nsstring *formatstring = [nsdateformatter dateformatfromtemplate:@"dd. mmmm" options:0 locale:germanlocale]; nsdateformatter *dateformat = [[nsdateformatter alloc] init]; [dateformat setdateformat:formatstring]; nsdate *datefrom = [dateformat datefromstring:@"20. september"]; nsdate *dateto = [dateformat datefromstring:@"20. februar"];
try setting locale of nsdateformatter:
nsdateformatter *dateformat = [[nsdateformatter alloc] init]; dateformat.locale = germanlocale; [dateformat setdateformat:@"dd. mmmm"]; nsdate *datefrom = [dateformat datefromstring:@"20. september"]; nsdate *dateto = [dateformat datefromstring:@"20. februar"];
Comments
Post a Comment