如何在 Flex / ActionScript 3 中检索特定于区域设置的日期格式字符串?
如何在 Flex / ActionScript 3 中检索特定于区域设置的日期格式字符串?我无法找到一种方法来根据当前区域设置返回实际格式字符串(指定日期格式)。我问这个问题是因为我希望找到一种方法,根据区域设置的当前短日期格式将字符串转换为日期。 Java 允许调用:
DateFormat format = DateFormat.getDateInstance(DateFormat.SHORT, locale)
检索 DateFormat 的实例,该实例根据基于区域设置的 SHORT 格式进行格式化。
Adobe Flex (ActionScript 3) 3 中是否存在类似的功能?如果没有,是否有可靠的第三方库可用?
How do I retrieve the locale-specific date format string in Flex / ActionScript 3? I am unable to find a method to return the actual format string (that which specifies the date format) based on the current locale. I am asking this question because I was hoping to find a way to convert a String to a Date based on the current SHORT date format for the locale. Java allows one to call:
DateFormat format = DateFormat.getDateInstance(DateFormat.SHORT, locale)
to retrieve an instance of DateFormat that formats according to the SHORT format based on the locale.
Does similar functionality exist in Adobe Flex (ActionScript 3) 3? If not, is there a reliable third party library that exists for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我刚刚发现这个包可以完成这项工作。这里描述了 DateTimeFormatter 类:
太酷了。
I'm just found this package that do the job. Here describe the class DateTimeFormatter:
Just cool.
扩展Gojan的答案:
Extending Gojan's answer:
是的,我不得不说 Java 在日期方面做得更好 - 你设置了语言环境,你的日期就会自动正确输出!我在Flex中似乎找不到这样的设施。
为了正确输出每个区域设置的日期,我认为您必须执行本文中所写的操作: http://livedocs.adobe.com/flex/3/html/help.html?content=l10n_1.html。也许您应该这样做,并且在同一个类中,只需将从语言环境文件中提取的这些字符串可供应用程序的其余部分使用,然后您就可以对它们进行操作。
否则也许这个人的图书馆会帮助你?我不知道。
http://flexoop.com/ 2008/12/flex-date-utils-date-and-time-format-part-ii/
Yeah I have to say Java is better with dates - you set the locale and automatically your dates are outputted correctly! I can't seem to find such a facility in Flex.
In order to output your dates correctly for each locale I think you have to do what is written in this article: http://livedocs.adobe.com/flex/3/html/help.html?content=l10n_1.html. Maybe you should do this, and in the same class just make these strings which you've pulled from the locale file available to the rest of your app, then you'll be able to operate on them.
Otherwise perhaps this guy's library will help you? I'm not sure.
http://flexoop.com/2008/12/flex-date-utils-date-and-time-format-part-ii/