Solved

Time Zones on Client/Server Side

Posted on 2002-03-24
1
155 Views
Last Modified: 2010-04-01
i created a simple form with 2 columns for
date and time. the date and time is used for scheduling a job in the server. each column is composed of 2 combo boxes for month, day, year and the other one is hour, min and seconds. what i want to happen is, the page will dynamically pre select the current date and time based on the server, but already converted to the clients' timezone. using javascript and jsp. do u guys have some existing code for this task? thx :)
of course the data submitted to the server is already converted to the servers' timezone too.
0
Comment
Question by:ibo
1 Comment
 

Accepted Solution

by:
mark_at_serialmonkey earned 20 total points
ID: 7038368
There is classes in Java that let you do timezone conversions. Below is a snippet of code.

Date created = new Date();
TimeZone tz = SimpleTimeZone.getTimeZone("Australia/Sydney");
Calendar calendar = new GregorianCalendar(tz);
DateFormat df = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT);
df.setCalendar(calendar);
String formattedCreated = df.format(created);

This will format the created date object into a String which is in Australia/Sydney time format. You could also do the reverse I imagine using df.parse(). Have a look at the javadoc around these classes.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Moving applications to the cloud or switching services to cloud-based ones, is a stressful job.  Here's how you can make it easier.
Find out what the Office 365 disclaimer function is, why you would use it and its limited ability to create Office 365 signatures.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now