Date in flex

Source: Internet
Author: User
Flex dateformatter and date attributes

Posted on
Edge element reading (1588) Comments (0)
Edit
Add the following public static function getdate (S: string): Date.
{

If (S. length> 0)
{
VaR Sarr: array = S. Split ("-");
If (Sarr. length> = 3)
Return new date (Sarr [0], INT (Sarr [1])-1, Sarr [2]);
}
Return new date (1970, 1, 1 );
} Public static function getdatestr (Dt: Date): String
{
VaR FMT: dateformatter = new dateformatter ();
FMT. formatstring = "YYYY-MM-DD ";
Return FMT. Format (DT );
} Public static function Format (date: date, formatstring: string): String
{
If (date = NULL ){
Return NULL;
}
VaR DF: dateformatter = new dateformatter ();
DF. formatstring = formatstring;
Return DF. Format (date );
} There is a constructor for date.public function Date(yearOrTimevalue:Object, month:Number, date:Number
= 1, hour:Number = 0, minute:Number = 0, second:Number
= 0,
millisecond:Number = 0)
Therefore, you can also write the public static function getdatetime (S: string): Date // 12:35:13
{
If (S. length> 0)
{
VaR SS: array = S. Split ("");
VaR Sarr: array = ss [0]. Split ("-");
VaR sarr1: array = ss [1]. Split (":");
Return new date (Sarr [0], INT (Sarr [1])-1, Sarr [2], sarr1 [0], sarr1 [1], sarr1 [2]);
}

Return new date (1970, 1, 1 );
}

Public static function getdatetime2 (S: string): Date // 2011-06-11
{
If (S = NULL | S = "")
Return new date (2010,0, 1 );

Else if (S. length> 0)
{
VaR SS: array = S. Split ("");
VaR Sarr: array = ss [0]. Split ("-");
Return new date (Sarr [0], INT (Sarr [1])-1, Sarr [2]);
}

Return new date (2010,0, 1 );
} Public static function getminutes (S: string): int
{
VaR DT: Date = getdatetime (s );
VaR dtnow: Date = new date ();
VaR DIFF: Number = (dtnow. gettime ()-Dt. gettime ()/1000;
Return diff/60;
}

Public static function getwaitingdate (S: string): String
{Var DT: Date = getdatetime (s );
VaR dtnow: Date = new date ();
VaR DIFF: Number = (dtnow. gettime ()-Dt. gettime ()/1000; // alert. Show (getdatestr2 (DT ));

VaR sret: String = "";
VaR ihour: Int = 0;
VaR iminute: Int = 0;
VaR ISEC: Int = 0;
If (diff> 3600*24)
{
VaR iday: Int = diff/(3600*24 );
// Sret = iday + "day ";
Diff = diff % (24x3600 );
}
Ihour = diff/3600;
If (ihour> 0)
Diff = diff % 3600;
Iminute = diff/60;
If (iminute> 0)
Diff = diff % 60;
ISEC = diff;
VaR Shour: String = ihour. tostring ();
If (Shour. Length = 1)
Shour = "0" + Shour;
VaR Smin: String = iminute. tostring ();
If (Smin. Length = 1)
Smin = "0" + Smin;
VaR ssec: String = ISEC. tostring ();
If (ssec. Length = 1)
Ssec = "0" + ssec;

Sret = sret + Shour + ":" + Smin + ":" + ssec;
Return sret;
} Attributes date and daydate that are easy to confuse:
Number returns the value of the day of the month specified by the date object according to the local time (an integer between 1 and 31 ).

Getdate (): Number returns the value of the day of the month specified by the date object based on the local time (an integer between 1 and 31 ).

Day: Number
[Read-Only] returns the week value specified by the date according to the local time (0 indicates Sunday, 1 indicates Monday, and so on ).

Getday (): Number returns the week value specified by the date according to the local time (0 indicates Sunday, 1 indicates Monday, and so on ).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.