Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(1)
tl; dr;
使用不变文化,如果您总是想获得
jun
:更长的解释
真的很有趣,为什么(有时)发生这种情况。
您应该检查您使用的文化的
缩写的monthgenitivenames
。重现它,
您可以重现行为,当您使用具有缩写的月份名称的文化时,与默认值不同:
解释
有一个解释在
abbreviatedMonthgenitivenames
的文档中
和也有一个问题也提到了这一点:
可能的解决方案
您可以使用不变文化来获取您要寻找的结果:
此结果:
tue> tue> tue>
TL;DR;
Use the invariant culture, if you always want to get
Jun
:Longer explanation
That's really interesting why this happens (sometimes).
You should check the values of your
AbbreviatedMonthGenitiveNames
of the culture you're using.Reproduce it
You can reproduce the behavior, when you use a culture with abbreviated month genitive names that differ from the default:
Explanations
There is an explanation in the documentation of
AbbreviatedMonthGenitiveNames
:and there is an issue where this is mentioned too:
Possible solution
You could use the invariant culture to get the result you are looking for:
This results in:
Tue Jun 21 2022