Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

timestamp with local time zone

Posted on 2010-08-13
7
Medium Priority
?
517 Views
Last Modified: 2013-11-23
I have database column insert_date timestamp(6) with local timezone.  In my java rowmaper class I have the following mapping.
muObj.setInsertDate(rs.getTimestamp("INSERT_DATE", Calendar.getInstance(TimeZone.getDefault())));

However in my jsp i don't see the correct date. I am in CST and I see a time 5 hours ahead i.e. GMT.  In the database column if I look at the dates are correct and is in CST.  Is there a double conversion going on which is making the date to show in GMT. I know I am doing something wrong in my rowmapper....
0
Comment
Question by:lotrzz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 26

Accepted Solution

by:
ksivananth earned 200 total points
ID: 33429440
looks like the server where the JSP hosted is running on GMT
0
 
LVL 26

Expert Comment

by:ksivananth
ID: 33429463
try changing the default timezone,

TimeZone.setDefault( TimeZone.getTimeZone( "CST" ) ) ;

make sure the CST is sup[ported, if not give the long name
0
 

Author Comment

by:lotrzz
ID: 33429472
it's my local tomact 6.0 server.... should be in CST too
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:lotrzz
ID: 33432348
I tried this... didn't help still I am getting time in GMT.

TimeZone myTz= TimeZone.getTimeZone("GMT-06:00");
TimeZone.setDefault(myTz);
muObj.setInsertDate(rs.getTimestamp("INSERT_DATE", Calendar.getInstance(TimeZone.getDefault())));

I printed out the timezone and it is showing GMT - 06:00
0
 
LVL 26

Expert Comment

by:ksivananth
ID: 33443797
you need to set the timezone before creating connection!
0
 

Author Comment

by:lotrzz
ID: 33453885
But I am using spring, so do I need to set this in the application-context file?
0
 

Author Closing Comment

by:lotrzz
ID: 33687725
I changed the server and re-installed tomcat again and that fixed the issue.  This was a issue with the server.
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

604 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