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
Solved

timestamp with local time zone

Posted on 2010-08-13
7
492 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
  • 4
  • 3
7 Comments
 
LVL 26

Accepted Solution

by:
ksivananth earned 50 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
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 

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

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

Title # Comments Views Activity
netstat -ano | find "8000" and taskkill /f /pid 2984 3 83
table example 4 32
Chrome and Firefox Java 5 50
intellij error 2 17
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

839 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