如何格式化DateTime或TimeZone / TimeZoneInfo显示三个字母? [英] How do I format DateTime or TimeZone/TimeZoneInfo to display Three letters?

查看:195
本文介绍了如何格式化DateTime或TimeZone / TimeZoneInfo显示三个字母?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在处理时间,OFX是一个特殊的日期时间格式,我不一定要使用(1 not 2)datetime必须以这样的格式加盖(DTCLIENT或DTSERVER):

20071015021529.000



然而,在示例中显示:

  20071015021529.000 [-8:PST] 

我没有问题,第一个使用

  DateTime.Now.ToString(yyyyMMddHHmmss.fff)

我甚至可以弄清楚如何获取%z 以获得正确的偏移量。



三字母时区代码是我绊倒的地方。有没有一个简单的方法来获取这个.net,或者我将最终编写代码来输出和解析我需要什么?

解决方案

您需要准确找出需要哪些3个字母的代码。例如,欧洲/巴黎会是什么?就个人而言,我会将数据转换为UTC,并将其格式化,除非您确实需要保留时区信息。


I'm working with a spec that calls for a peculiar Datetime format that I haven't necessarily had to work with yet.

At Process time, an OFX (1 not 2) datetime must be stamped (either DTCLIENT or DTSERVER) in a format like this:
20071015021529.000

however, in the examples it is shown:

20071015021529.000[-8:PST]    

I don't have a problem with the first one using a statement of

DateTime.Now.ToString("yyyyMMddHHmmss.fff")

I can even figure out how to get %z to get the correct offset.

The three letter timezone code is where I'm tripping up. Is there an easy way to get this in .net, or am I going to end up writing code to output and parse what I need?

解决方案

You need to find out exactly which 3 letter codes it needs. What would Europe/Paris give, for example? Personally, I'd convert the data to UTC and format it that way, unless you actually need to preserve the time zone information.

这篇关于如何格式化DateTime或TimeZone / TimeZoneInfo显示三个字母?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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