如何解析Flex(AS3)中的ISO格式化日期? [英] How to parse an ISO formatted date in Flex (AS3)?

查看:158
本文介绍了如何解析Flex(AS3)中的ISO格式化日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Flex(AS3)中将ISO日期字符串解析为日期对象?

How can I parse an ISO date string into a date object in Flex (AS3)?

例如

2009-12-08T04: 23:23Z

2009-12-08T04:23:23.342-04:00

etc ...

e.g.
2009-12-08T04:23:23Z
2009-12-08T04:23:23.342-04:00
etc...

推荐答案

import com.adobe.utils.DateUtil;

var dateString:String = "2009-03-27T16:28:22.540-04:00";
var d:Date = DateUtil.parseW3CDTF(dateString);
trace(d);
var s:String = DateUtil.toW3CDTF(d);
trace(s);




[trace] Fri Mar 27 16:28:22 GMT-0400 2009
[trace] 2009-03-27T20:28:22-00:00

得出 DateUtil 处理 W3C日期和时间规格。 AS3日期不保持毫秒,但如果可用,它们将被丢弃。

Turns out DateUtil handles everything in the W3C Date and Time spec. AS3 Dates do not maintain milliseconds, but they'll just be dropped if available.

请注意,W3C输出将转换为UTC(也称为GMT或Zulu时间)。

Note that the W3C output is converted to UTC (aka GMT, or Zulu time).

这篇关于如何解析Flex(AS3)中的ISO格式化日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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