![]() |
![]() |
||||||
|
|||||||
| Tags: convert, date, object, string |
![]() |
|
|||
|
hi,
I'm puzzled by a DATE question: I retrieved a date from my database ,and converted the sqlResult into a XML. so the date become a string in my xml. when I fill the xml data to the DataGrid , I want to use the DateFormatter to format the string of date. It's failed .Because the method only can format date object . I searched in the help doc and searched in google.I haven't got a way how to covert a date string to the date object. my date string from the XML like this:[h]Fri Jun 13 00:00:00 GMT+0800 2008[/h] I try to use String as Date to covert it .but the output is Null. I have no way to settle the matter. wait for your help thx! |
| Sponsored Links |
|
|||
|
DateField has static method that oes that :
stringToDate () method public static function stringToDate(valueString:String, inputFormat:String) ateParses a String object that contains a date, and returns a Date object corresponding to the String. The inputFormat argument contains the pattern in which the valueString String is formatted. It can contain "M","D","Y", and delimiter and punctuation characters. The function does not check for the validity of the Date object. If the value of the date, month, or year is NaN, this method returns null. Parameters valueString:String ? Date value to format. inputFormat:String ? String defining the date format. Returns Date ? The formatted date as a Date object. Example var dob ate = DateField.stringToDate("06/30/2005", "MM/DD/YYYY"); |
|
|||
|
On Jun 16, 5:46 pm, "kyalong" <webforumsu...@macromedia.com> wrote:
> hi, > > I'm puzzled by aDATEquestion: > > I retrieved adatefrom my database ,and converted the sqlResult into a XML. > so thedatebecome astringin my xml. > > when I fill the xml data to the DataGrid , I want to use the DateFormatter to > format thestringofdate. > It's failed .Because the method only can formatdateobject. > > I searched in the help doc and searched in google.I haven't got a way how to > covert adatestringto thedateobject. > > mydatestringfrom the XML like this:[h]Fri Jun 13 00:00:00 GMT+0800 2008[/h] > > I try to useStringasDateto covert it .but the output is Null. > > I have no way to settle the matter. > > wait for your help thx! Well looks like you're trying to convert a RFC822 date format. If you look at the Flex3 docs for the Date Object (the constructor), it'll give you some examples of how to convert your string to a Date Object. Here's how it would look like: var myDate ate = new Date("Fri Jun 13 00:00:00 GMT+0800 2008");Also, if you're dealing with other formats like the W3C date format, you can use the open-source library as3corelib, and there's a class called com.adobe.utils.DateUtil, which should do the trick. |
|
|||
|
For the structure of your date I have most of it here but I don't think there
is a formatter for GMT. Example as follows. However I think you could make it much easier on yourself by formatting the date to a much easier format on the SQL side first before it even hits Flex. var dob ate = DateField.stringToDate("Fri Jun 13 00:00:00 GMT+0800 2008","EEE MMM DD HH:NN:SS ???+HHNN YYYY"); SQL -------------------------------------------------------------------------------- ------------------------------- SELECT date_format(fld_dob, '%m/%d/%Y') AS dob FROM table |
|
|||
|
For the structure of your date I have most of it here but I don't think there
is a formatter for GMT. Example as follows. However I think you could make it much easier on yourself by formatting the date to a much easier format on the SQL side first before it even hits Flex. var dob ate = DateField.stringToDate("Fri Jun 13 00:00:00 GMT+0800 2008","EEE MMM DD HH:NN:SS ???+HHNN YYYY"); SQL -------------------------------------------------------------------------------- ------------------------------- SELECT date_format(fld_dob, '%m/%d/%Y') AS dob FROM table |
|
|||
|
Thx!
I had settled the matter. data.transDate is a String like:Fri Jun 13 00:00:00 GMT+0800 2008 ------------------------------------------------------ var milliseconds:Number = Date.parse(data.transDate); var mydate ate = new Date(milliseconds);var mydateStr:String = DateField.dateToString(mydate,"YYYY-MM-DD") |
|
|||
|
Publish Your Custom Message On Millions of Forums Worldwide
We can publsih your custom message on forums, blogs and message systems worldwide. Unlike Google Ads that are static, we actually penetrate into online exisiting forums to post your messages. You can promote your website, product and/or services. In fact, this post was published by automated means! Main Promotional Services: ** Posts will appear just as this post appears ** All custom posts will appear to have been published by unique users ** Exploit your commericial potential by posting on forums relative to your business ** Ability to Randomize & Rotate Posts for Increased Uniqueness ** Send Mass PM messages to forum members worldwide with your custom message Please Note - I am offering a service, not software. Please refer to my online step-by-step movie demonstration listed below proving how I can post your website, product or services on millions of websites worldwide. This will increase your web traffic, increase your potential sales, and also increase the amount of 3rd party websites that will link back to your site - which convinces major search engines of the popularity of your website. Many of the posts are published on PR6, PR7 and PR8 Google ranked websites. Online Video Demonstration Please watch this 5 minute video demonstrating how your custom post will be published Click Here to Watch Automated Forum Posting Demonstration Contact me If Your Interested ICQ: 162456288 Gmail Chat: sharepro at gmail.com More Info: Demya.com Btw - If you want to purchase pre-made established and promoted niche mp3 music, video, game and other social websites, please refer to Demya.com |
|
|||
|
|
|
|||
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
- Contact Us
-|-
Adobe Dreamweaver Forums -|-
Archive -|-
Top -|-Rules/Disclaimer-|-Help/Support-|-Advertise