DateFormatter格式化时间的两种小时格式

来源:互联网 发布:洛阳师范学院(软件类) 编辑:程序博客网 时间:2024/05/01 22:18

1. 目的:本例将对Flex的DateFormatter格式化时间的两种小时格式进行测试。

2. 测试代码:

DateFormatterTest.mxml

<?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" x="10" y="10"   creationComplete="init(event)"   ><s:layout><s:VerticalLayout/></s:layout><fx:Script><![CDATA[import mx.controls.Alert;import mx.events.FlexEvent;protected function init(event:FlexEvent):void{showTI1.text = dateFormatter1.format("2014-9-25 0:30:30");showTI2.text = dateFormatter2.format("2014-9-25 0:30:30");}]]></fx:Script><fx:Declarations><!-- JJ是0-23小时制式的,HH是0-24小时制式的。需要注意的是虽然HH是0-24制的,但凌晨不能写成24,24时只能用0时表示,JJ格式同样不能写成24--> <mx:DateFormatter id="dateFormatter1" formatString="YYYY-MM-DD JJ:NN:SS" /><mx:DateFormatter id="dateFormatter2" formatString="YYYY-MM-DD HH:NN:SS" /></fx:Declarations><s:HGroup><s:Label text="日期格式1:" /><s:TextInput id="showTI1"  /></s:HGroup><s:HGroup><s:Label text="日期格式2:" /><s:TextInput id="showTI2"  /></s:HGroup></s:Application>

3. 测试结果


0 0