不能在NSDateFormatter中的年份之前放置单引号 [英] Can't put a single quote before the year in NSDateFormatter

查看:179
本文介绍了不能在NSDateFormatter中的年份之前放置单引号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要将日期格式设置如下:

I want to format my date as follows:

Mon, Apr 14 '09

dateFormat 我为我的 NSDateFormatter EEE,MMM dd'yy ,但它显示:

The dateFormat I'm setting for my NSDateFormatter is EEE, MMM dd 'yy but it shows:

Mon, Apr 14 'yy

如果我在一年前拿出单引号,我得到一年的最后两位数字,但不是很明显,这是一年,因为单引号已经走了。帮助?

If I take out the single quote before the year, I get the last two digits of the year but it's not obvious that it's the year because the single quote is gone. Help?

我也尝试过''''\' ''\''''之前'yy',但它不工作,虽然最后两个产生'yy ''09

I've also tried putting ''', '\'', and '\''' before 'yy' but it doesn't work, although the last two produced 'yy and ''09

推荐答案

http://www.unicode.org/reports /tr35/tr35-31/tr35-dates.html#Date_Format_Patterns


在模式中,两个单引号表示文字单引号,...

In patterns, two single quotes represents a literal single quote, …

在您的情况下:

 [formatter setDateFormat:@"EEE, MMM dd ''yy"];

这篇关于不能在NSDateFormatter中的年份之前放置单引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆