Date Class time units values example


 

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.

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>

0

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

<mx:Text id="mytext0"/>

</mx:HBox>

1

<mx:HBox>

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

<mx:Text id="mytext1"/>

2

</mx:HBox>

<mx:HBox>

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

3

<mx:Text id="mytext2"/>

</mx:HBox>

<mx:HBox>

4

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

<mx:Text id="mytext3"/>

</mx:HBox>

5

<mx:HBox>

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

<mx:Text id="mytext4"/>

6

</mx:HBox>

<mx:HBox>

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

7

<mx:Text id="mytext5"/>

</mx:HBox>

<mx:HBox>

8

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

<mx:Text id="mytext6"/>

</mx:HBox>

9

<mx:HBox>

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

<mx:Text id="mytext7"/>

0

</mx:HBox>

</mx:VBox>

</s:Panel>

1

</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:-

2

Download this code

Ads