?
Solved

timestamp with local time zone

Posted on 2010-08-13
7
Medium Priority
?
510 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
Stressed Out?

Watch some penguins on the livecam!

 

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

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!

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
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:
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses
Course of the Month8 days, 20 hours left to enroll

764 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