AS3:ISO8601转换日期/时间

时间:2014-08-27 07:01:25

标签: actionscript-3

我的代码:

var util:ISO8601Util = new ISO8601Util();

var date:Date = util.parseDateTimeString("2014-08-01T10:36:19+08:00");
var currentdate:Date = new Date();

var extended:String = util.formatExtendedDateTime( currentdate )
var basic:String = util.formatBasicDateTime( currentdate );
trace("currentdate:" + currentdate);
trace("=============================");
trace("Extended: "+extended);

我的parseDateTimeString代码:

 public function parseDateTimeString( val:String ):Date
        {
            //first strip all non-numerals from the String ( convert all extended dates to basic)
            val = val.replace( /-|:|T|Z/g, "" );

            var date:Date = parseBasicDate( val.substr( 0, 8 ) );
            date = parseBasicTime( val.substr( 8, 6 ), date );

            return date;
        }

输出:

   currentdate:Wed Aug 27 15:00:02 GMT+0800 2014
=============================
Extended: 2014-08-27T07:00:02Z

如您所见,当前日期的时间是15:00:02:[3:00 PM]但是当我尝试将其转换为tru扩展ISO8601时输出06:48:42 [7:00 AM]

为什么扩展ISO8601的输出错误?

请帮帮我..

我只是在这里得到代码..

http://www.brooksandrus.com/blog/2009/02/23/convert-an-iso-8601-date-string-to-from-a-native-as3-date-object/

谢谢!

1 个答案:

答案 0 :(得分:0)

您是否尝试过使用com.adobe.utils.DateUtil中的方法parseW3CDTF?