Solved

Time Zones on Client/Server Side

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
In 2017, ransomware will become so virulent and widespread that if you aren’t a victim yourself, you will know someone who is.
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 is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

895 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

14 Experts available now in Live!

Get 1:1 Help Now