在 WP7 上正确格式化 DateTime.ToShortTimeString()? [英] Formatting DateTime.ToShortTimeString() correctly on WP7?

查看:26
本文介绍了在 WP7 上正确格式化 DateTime.ToShortTimeString()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有时打印如下:

dateTime.ToShortTimeString();

这会打印出类似3:21 PM"的内容,即使用户的手机设置为将时间显示为15:21 PM".有没有办法让 dateTime 使用一些本地化/格式化参数来考虑这一点?

This prints out something like "3:21 PM", even if the user's phone is set to display times as "15:21 PM". Is there a way I can make dateTime use some localization/formatting parameter to take this into account?

推荐答案

如果您需要它作为绑定的一部分,您可以使用 ValueConverter.请注意,在 ValueConverter

If you need it as part of a Binding, you could use a ValueConverter. Just mind you there's a "bug" when formatting dates in a ValueConverter

写了一篇关于这个主题的博文,并附有代码示例如何将其用于 XAML 中的日期格式.

I wrote a blog post on the subject with code samples on how to utilize it for in-XAML date formatting.

这篇关于在 WP7 上正确格式化 DateTime.ToShortTimeString()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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