Keep same timezone on all clients in different timezones

We work on a Flex application (sdk 3.4), we need to display dates stored in a mysql database with a Java application server by BlazeDS. But we must make treatments on the dates in flex application. All with the same timezone that can be stored in the database.

The best solution found so far is to manipulate the dates during the transfer BlazeDS: http://cookbooks.adobe.com/post_Date_time_transfer_in_BlazeDS-13114.html

This solution does not solve the problem of instantiating the date made flex side and treatment on those dates.

Do you have a more general solution? Knowing that the class date is final and that it is not possible to set timezone on flash player
KCTeamAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

wannabetechieCommented:
If you are not interested in showing the date with the timezone of the client then cant the date stored in your database be converted into a String while sending back the data to the Flex.
Probably can be done as part of your business logic which creates the Java objects that needs to be sent to the BlazeDS.
0
KCTeamAuthor Commented:
This solution may be  good for display but not for the instantiating and treatments made on flex application side.
0
petiexCommented:
What I do is to get the server GMT offset in minutes with this line of Java:
int minutesOff = TimeZone.getDefault().getOffset(new Date().getTime()) / 60000;

and, when the application loads, pass that value into it, and store that to a global variable, call it gOffset: int.

So, to generate a timestamp on the client using the server's offset, or whichever other offset you want, you can use the getCurrentServerTime() function below.
public var gOffset; //set from the server at some point before 
                    // calling getCurrentServerTime

/**
* Returns the current time adjusted to the server's timezone  
* (gOffset).
*/
public function getCurrentServerTime():Date{
        var now:Date = new Date();
        // date.getTimezoneOffset() returns
        // "The minutes you need to add to the computer's local 
        // time value to equal UTC."
        // so, for EST it gives you 300 instead of -300. 
       // Opposite of java.
        var clientOffset:Number = - now.getTimezoneOffset(); 
        var nowTime:Number = now.getTime();
        var adjustedOffset:Number = gOffset - offset,
        var milliOffset:Number = adjustedOffset * 60000;
        //convert client time to center time
        nowTime += (milliOffset);
        now = new Date(nowTime);
        return now;
}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
KCTeamAuthor Commented:
The  solution is interesting , but we wanted a more general since the  application is already implemented so we wanted to have one solution  does not require changing all instantiating like to change the TimeZone  of flash player
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.