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

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

问题描述

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

例如
2009-12-08T04:23:23Z
2009-12-08T04:23:23.342-04:00
等等...

解决方案

import com.adobe.utils.DateUtil;var dateString:String = "2009-03-27T16:28:22.540-04:00";var d:Date = DateUtil.parseW3CDTF(dateString);追踪(d);var s:String = DateUtil.toW3CDTF(d);痕迹;

<前>[跟踪] 2009 年 3 月 27 日星期五 16:28:22 GMT-0400[跟踪] 2009-03-27T20:28:22-00:00

结果是 DateUtil 处理W3C 日期和时间 规范.AS3 日期不保持毫秒,但如果可用,它们会被删除.

请注意,W3C 输出已转换为 UTC(又名 GMT,或祖鲁时间).

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

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

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.

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

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

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