Get Date Object without TimeZone

172 views
Skip to first unread message

Madan Narra

unread,
Nov 17, 2009, 5:10:23 AM11/17/09
to flex_...@googlegroups.com
Hi All,

Is it possible to create a Date object without holding the TimeZone ?

The date object should just be "Thu Nov 19 00:00:00 2009 " instead of "Thu Nov 19 00:00:00 GMT-0500 2009 " just ignoring the time zone

Any ideas how to implement this.

--
Thanks,
Madan N

Madan Narra

unread,
Nov 17, 2009, 7:59:16 AM11/17/09
to flex_...@googlegroups.com
Explaining a bit more on the question I raised earlier.

We have an issue in a custom component, The issue is being caused only in TimeZones which are effected by the Day Light Savings.

As we are aware, that day light savings changed from this Sun ,November 1st 2009, only than we are aware of this.

Below is sample test written FYI,

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:local="*">
    <mx:Script>
        <![CDATA[
            import mx.controls.Alert;
           
            private function test():void {
                var date1:Date = new Date(2009,10,1,0);
                var date2:Date = new Date(2009,10,1,1);
                Alert.show("Date 1 :: "+date1+"   Date 2 :: "+date2);
            }
        ]]>
    </mx:Script>
    <mx:Button click="test()" label="Test"/>
</mx:Application>

When created a Date object for 00:00 and 01:00 hours on 1st Nov, these are the results appeared
Date 1 :: Sun Nov 1 00:00:00 GMT-0400 2009  
Date 2 :: Sun Nov 1 01:00:00 GMT-0500 2009

As observed, at Nov 1 00:00 the GMT is -0400 and at Nov 1 01:00 the GMT is -0500. This is causing a bit of unknown errors in the component.

So the question, is there a way to Ignore the local timezone and just make use of Date object.

PS: I tried converting the local time to UTC. This didn't work out.

Madan N
--
Thanks,
Madan N

eld...@gmail.com

unread,
Nov 17, 2009, 6:40:29 AM11/17/09
to Flex India Community
try to use UTC methods!

sathesh

unread,
Nov 17, 2009, 5:52:00 AM11/17/09
to Flex India Community
hi,

Use DateFormatter to get the Date in the format you want

example:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:DateFormatter id="formatDateTime" formatString="EEE MMM DD
L:NN:SS YYY" />
<mx:Label text="{formatDateTime.format(new Date()) }"/>
</mx:Application>

ya meng

unread,
Nov 17, 2009, 6:57:33 AM11/17/09
to flex_...@googlegroups.com
using dataFormatter in flex

2009/11/17 Madan Narra <madan.f...@gmail.com>

--

You received this message because you are subscribed to the Google Groups "Flex India Community" group.
To post to this group, send email to flex_...@googlegroups.com.
To unsubscribe from this group, send email to flex_india+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/flex_india?hl=.

Madan Narra

unread,
Nov 17, 2009, 8:15:33 AM11/17/09
to flex_...@googlegroups.com
As I said earlier, Am expecting a DATE object without TimeZone. Formatting a Date Object returns me a String !!

Also, I tried Converting the Date to UTC or using the UTC methods available. They didnt help me out.

Madan N

ManoharMP

unread,
Dec 31, 2009, 5:38:00 AM12/31/09
to flex_...@googlegroups.com

Hi Madan,

Below method might be useful for you.

public static function getDateWithoutTime(date:Date):Date{
var dateFeild:DateField = new DateField();
dateFeild.selectedDate = date;
return dateFeild.selectedDate;
}

This method will return the date without time

> --
>
> You received this message because you are subscribed to the Google Groups
> "Flex India Community" group.
> To post to this group, send email to flex_...@googlegroups.com.
> To unsubscribe from this group, send email to
> flex_india+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/flex_india?hl=.
>
>
>
>

--
View this message in context: http://old.nabble.com/-flex_india%3A26696--Get-Date-Object-without-TimeZone-tp26387298p26977121.html
Sent from the Flex India mailing list archive at Nabble.com.

Norris.Lin

unread,
Jan 1, 2010, 11:02:02 AM1/1/10
to flex_...@googlegroups.com
Nice~

2009/12/31 ManoharMP <manoh...@rediffmail.com>
For more options, visit this group at http://groups.google.com/group/flex_india?hl=en.





--
Everyday is a New Life. My Blog:http://norris-lin.blogbus.com/

Reply all
Reply to author
Forward
0 new messages