是否可以在NSDateFormatter的格式string中添加自定义文本?
假设我想让date看起来像这样:
|1988|December|30|
如何将这些添加到dateFormatter或为此,让格式是这样的:
30 in the month of December in the year of 1998
现在是1988年,12月和30日,我想用标准格式,但是我想要的文字也陪在他们身上。
特别是在上述情况下,格式和pipe道只与格式和pipe道之间没有空间的date或月份的date格式相邻。
这是可能的任何设置格式?
例如,您可以在date格式中插入任意文本(用单引号括起来)。
NSDateFormatter *fmt = [[NSDateFormatter alloc] init]; [fmt setDateFormat:@"dd' in the month of 'MMMM' in the year of 'yyyy"]; NSString *s = [fmt stringFromDate:[NSDate date]];
结果:
09年7月在2013年