Solved

Time Zones on Client/Server Side

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
squirrelPlay java challenge 40 158
maven j2ee examles 2 60
Use tracing facilities in your browser steps 2 122
ejb on wildfly 5 30
Many businesses neglect disaster recovery and treat it as an after-thought. I can tell you first hand that data will be lost, hard drives die, servers will be hacked, and careless (or malicious) employees can ruin your data.
There's a lot of hype surrounding blockchain technology. Here's how it works and some of the novel ways it' s now being used - including for data protection.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

808 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