Date Class with multiple numeric parameter constructor


 

Date Class with multiple numeric parameter constructor

In this example we have created Date class object and pass multiple numeric parameters.

In this example we have created Date class object and pass multiple numeric parameters.

Date class with multiple numeric parameters to the Date() constructor example:-

In this example we have created Date class object and pass multiple numeric parameters as  the year, month, day, hour, minute, second, and millisecond, respectively, and returns a corresponding Date object. The date class object take time information of the midnight to the related date. This is the example of multiple numeric parameterized constructor 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(2010, 5, 1, 0, 0, 0, 0);

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

0

</mx:HBox>

</mx:VBox>

</s:Panel>

1

</s:Application>

In this example we have pass values 2010 for year , 5 for month, 1 for day, 0's for hours, minutes, seconds, and milliseconds. Users note that the month value is starts 0 to11 so the numeric value 5 have corresponding month is June.

Output:-

2

Download this code

Ads