在 Flex 中将字符串模式解析为日期 [英] Parse string pattern into Date in Flex

查看:28
本文介绍了在 Flex 中将字符串模式解析为日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

flex 中是否有某种方法可以解析当前的字符串.我希望它支持类似于dateformatter"的自定义格式.使用dateformatter"类,我们可以解析formatString 属性"指定的各种字符串格式的日期对象.我想要反过来,从字符串到日期.解析方法 'Date.parse(my_string)' 进行字符串解析,但格式非常有限.我们不能有类似下面的东西,用户可以指定他/她自己的格式.

Is there some way in flex to parse strings to date. I want it to support custom formats similar to 'dateformatter'. Using 'dateformatter' class we can parse date object in various string formats as specified by 'formatString property'. I want it other way round, from string to date. The parse method 'Date.parse(my_string)' does string parsing but for a very limited set of formats. Can't we have something similar to following, where user can specify his/her own formats.

someformatter.formatString = 'HH::MM::SS' ;
mydate = someformatter.formatTodate('23::56:34');

dateformatter 的 'parseDateString' 方法在这里有用吗?

Will 'parseDateString' method of dateformatter be useul here?

提前致谢.

推荐答案

可以使用

DateField.StringToDate()

这是DateField类的静态函数,返回Date对象.

This is static function of DateField class, and returns Date object.

这篇关于在 Flex 中将字符串模式解析为日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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