Solved

Time Zones on Client/Server Side

Posted on 2002-03-24
1
157 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Data breaches are on the rise, and companies are preparing by boosting their cybersecurity budgets. According to the Cybersecurity Market Report (http://www.cybersecurityventures.com/cybersecurity-market-report), worldwide spending on cybersecurity …
February 24, 2017 — On February 23, Travis Ormandy, a vulnerability researcher at Google, reported on Twitter (https://twitter.com/taviso/status/834900838837411840) that massive stores of data have been leaked by CloudFlare, a company that provide…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

810 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