Get start with Spark DateTimeFormatter in Flex 4.5 – Video中文教程

在下面的视频当中,我将会为大家介绍如何使用Spark DateTimeFormatter来创建小的应用程序。

Play Video – DateTimeFormatterDemo


Flex 4.5中globalization相关新功能示例

随着Flex 4.5的推出,一些有关globalization(全球化)的新功能也随之出炉。考虑到开发者对程序全球化的开发需求,我们为此创建了一批与全球化相关的新功能的示例。这些示例主要涵盖以下这些类:









Sort and SortField

目前这些示例多为英语,我们正在考虑添加更多的中文示例。开发者可以通过从Adobe官网安装‘Tour De Flex’ 来获得这些示例, 安装地址为:

How to format a date in locale-sensitive way

In the coming new release of Flex SDK – ‘Hero’, it provides new features on the globalization support. DateTimeFormatter is such a class can help you format a date in locale-sensitive way. In this article, I will introduce you how to create an application to format a date based on locale setting.

First, you need to install the IDE for developing a Flex application, Flash Builder or Eclipse are all good choices. Then, you can download the Flex SDK ‘Hero’ from . After set up development environment, we can go ahead to build our application.

First, create a comboBox in which contains different locales for users to choose.

<s:ComboBox id=”localesCB” dataProvider=”{ new ArrayCollection(['ar-SA','en-GB','fr-FR','ja-JP','ru-RU','zh-CN'])}”/>

Second, create an instance of DateTimeFormatter (which is under spark namespace) in MXML declarations, and bind its locale property with above comboBox’s selected value.


<s:DateTimeFormatter id=”dtf” locale=”{localesCB.selectedItem}”/>


Then, create a dateChooser to pick up the date to format.

<mx:DateChooser id=”dateDC”/>

At last, since the format function of DateTimeFormatter is bindable, we can bind its format result with a label. That will be:

<s:Label id=”resultL” text=”{dtf.format(dateDC.selectedDate)}”/>

DONE! That is all you need to do! Really simple, right?

Let us see what does the app looks like:

When choose en-GB as locale:

When choose zh-CN as locale:

When choose ar-SA as locale:

For more info about DateTimeFormatter, please visit:


北京时间2011年3月11日 13:46, 日本本州岛附近海域发生强烈地震,地震引发海啸.

在此, 为日本震区民众祈福~~~

Hello world!

This is a begining … …