flex中日期的格式化
今天我做的项目中需要把时间给拆分了,形式为:yyyy-MM-DD HH mm,
下面是我的代码实现:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
width="100%" height="100%"
>
<fx:Declarations>
<mx:DateFormatter id="dateFormat" formatString="YYYY-MM-DD JJ:NN:SS"/>
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.formatters.*;
[Bindable]
private var time:Date=new Date();
private function TestDateTimeToString():void
{
var fr:DateFormatter=new DateFormatter();
var fs:DateFormatter=new DateFormatter();
var ft:DateFormatter=new DateFormatter();
fr.formatString="YYYY-MM-DD JJ:NN:SS";
fs.formatString="JJ";
ft.formatString="NN";
myDate.text=fr.format(time);
hour.text=fs.format(time);
minutes.text=ft.format(time);
}
]]>
</fx:Script>
<mx:Panel width="100%" height="100%">
<mx:Label id="currentTimeText" text="当前日期:"/>
<mx:Label id="currentTime" text="{dateFormat.format(time)}"/>
<mx:Button label="转换日期" click="TestDateTimeToString()"/>
<mx:Label id="myDate" text="时间还没有被转换" />
<mx:Label id="hour" text="时间还没有被转换"/>
<mx:Label id="minutes" text="时间还没有被转换"/>
</mx:Panel>
</s:Application>
效果如下:
最新文章
- Sentiment Analysis resources
- Scrapy001-框架初窥
- live555 直播arm-linux视频
- MVC中的CSRF解决方案
- Network 分类: POJ 图论 2015-07-27 17:18 17人阅读 评论(0) 收藏
- shell学习总结之自定义函数
- careercup-递归和动态规划 9.4
- Js regular exprission
- ";git rm"; 和 ";rm"; 的区别
- Unity 获取服务器时间 HTTP请求方式
- 【转】DHCP协议详解
- 剑指Offer_4_二维数组中的查找
- HTTP相关:TCP/IP、DNS
- mysql 在visual studio中的配置
- numpy的数组常用运算练习
- Bootstrap-3-Typeahead
- mongodb创建用户(转发)
- leetcode(js)算法之696计数二进制串
- ionic 前端接收到后台推送来的消息后,显示在手机的通知栏上
- VS2015 无法启动 IIS服务器