Home Tutorial Flex Flex4 Components Date Class In Action Script

 
 

Share on Google+Share on Google+
Date Class In Action Script
Posted on: June 2, 2010 at 12:00 AM
Advertisement
If user want to deal with date and time in the application then it can be used Date class that provide date and time related information.

Date Class in Action Script 3:-

If user want to deal with date and time in the application then it can be used Date class that provide date and time related information. User access the current date and time, in local time based on your time zone with the help of  Date class in the application. The Date class is the top-label class that provide date and time related information. we can access and manipulate the date and time with the help of  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 = (String)(currdate.toDateString());

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

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

}

]]>

</fx:Script>

<s:Panel width="335" height="130" title="Date Class Panel" backgroundColor="0xE0FFFF">

<mx:VBox>

<mx:HBox>

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

<mx:Text id="mytext"/>

</mx:HBox>

<mx:HBox>

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

<mx:Text id="mytext1"/>

</mx:HBox>

<mx:HBox>

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

<mx:Text id="mytext2"/>

</mx:HBox>

</mx:VBox>

</s:Panel>

</s:Application>

In this example we have created a Date class object and get the current date and time. In this example user can see how to create a Date class object in the application. Date class have four types of constructor. This example used without parameter constructor.

Output:-

Download this code

Date Class with multiple numeric parameter constructor
In this example we have created Date class object and pass multiple numeric parameters.
 
Date Class with Single String parameter constructor example
The Date class have a single string parametrized constructor.
 
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.
 
Advertisement

Related Tags for Date Class In Action Script:


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