本文介绍了Silverlight使用String("G")作为格式在Mac而非PC上显示时区信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个显示一些数据的Silverlight应用程序.我使用DateTimeConverter将DateTime值转换为String.我使用dateTime.ToString("G")格式,然后又返回01/01/2010 12:01或类似的内容.到目前为止一切顺利.

I've got a Silverlight application that shows some data.I use a DateTimeConverter to convert the DateTime value into a String.I use the dateTime.ToString("G") format and I get back 01/01/2010 12:01 or something like that.So far so good.

但是,在Mac上,相同的应用程序显示01/01/2010 12:01 +02:00.这是时间CET,当前时间与UTC偏移(因此UTC时间为10:01).

However, the same application on a Mac shows 01/01/2010 12:01 +02:00. That's the time CET with the current offset from UTC (so the time UTC is 10:01).

这是怎么回事? Mac上有特殊设置吗?我使用了系统设置,并从文本格式中删除了CET和其他字符,但仍然得到了完全相同的结果.这是一个错误吗?

What is going on? Is there a special setting on the Mac? I played with the system settings and removed the CET and others from the text format but I still get the exact same result.Is this a bug?

当我按照答案中的建议显示格式模式时,在PC上为HH:mm:ss在Mac上为HH:mm:ss zzzz.干杯.

when I display the format pattern as suggested in the answer, I have HH:mm:ss on the PC and HH:mm:ss zzzz on the Mac.Cheers.

推荐答案

这表明LongTimePattern在Mac上是不同的. ("G"格式说明符表示短日期和长时间模式".)

That suggests the LongTimePattern is different on the Mac. (The "G" format specifier means "Short date and long time pattern".)

尝试在两个平台上显示CultureInfo.CurrentCulture.DateTimeFormat.LongTimePattern并查看其内容.

Try displaying CultureInfo.CurrentCulture.DateTimeFormat.LongTimePattern on both platforms and see what they say.

这篇关于Silverlight使用String("G")作为格式在Mac而非PC上显示时区信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 09:40