Home Tutorial Flex Flex4 Components Date Class time units values example

 
 

Share on Google+Share on Google+
Date Class time units values example
Posted on: June 2, 2010 at 12:00 AM
Advertisement
Through this example, user can see how to access the different units of time through Date object using properties or methods of the Date class.

Date class time units values example:- 

Through this example, user can see how to access the different units of time through Date object using  properties or methods of the Date class.

Example:-

<?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" creationComplete="init();">

<fx:Script>

<![CDATA[

public function init():void{

var currdate:Date = new Date();

mytext.text = (currdate.toLocaleString());

mytext0.text = (String)(currdate.getFullYear());

mytext1.text = (String)(currdate.month);

mytext2.text = (String)(currdate.date);

mytext3.text = (String)(currdate.day);

mytext4.text = (String)(currdate.hours);

mytext5.text = (String)(currdate.minutes);

mytext6.text = (String)(currdate.seconds);

mytext7.text = (String)(currdate.milliseconds);

}

]]>

</fx:Script>

<s:Panel width="300" height="280" title="Date Class Panel with Time units value" backgroundColor="0xE0FFFF">

<mx:VBox>

<mx:HBox>

<mx:Label text="The Current Date :"/>

<mx:Text id="mytext"/>

</mx:HBox>

<mx:HBox>

<mx:Label text="The Full Year :"/>

<mx:Text id="mytext0"/>

</mx:HBox>

<mx:HBox>

<mx:Label text="The Month :"/>

<mx:Text id="mytext1"/>

</mx:HBox>

<mx:HBox>

<mx:Label text="The Date :"/>

<mx:Text id="mytext2"/>

</mx:HBox>

<mx:HBox>

<mx:Label text="The Day :"/>

<mx:Text id="mytext3"/>

</mx:HBox>

<mx:HBox>

<mx:Label text="The Hours :"/>

<mx:Text id="mytext4"/>

</mx:HBox>

<mx:HBox>

<mx:Label text="The Minutes :"/>

<mx:Text id="mytext5"/>

</mx:HBox>

<mx:HBox>

<mx:Label text="The Seconds :"/>

<mx:Text id="mytext6"/>

</mx:HBox>

<mx:HBox>

<mx:Label text="The MiliSeconds :"/>

<mx:Text id="mytext7"/>

</mx:HBox>

</mx:VBox>

</s:Panel>

</s:Application>

In this example, we have created a Date class object after that we have used some properties or method of  Date class to find the time units value. User can see these properties in the example.

Output:-

Download this code

Advertisement

Related Tags for Date Class time units values example:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: June 2, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com