Solved

timestamp with local time zone

Posted on 2010-08-13
7
485 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
matchUp  challenge 9 71
Fibonacci challenge 11 82
countAbc challenge 9 49
computer science syllabus 3 52
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
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 …

707 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

15 Experts available now in Live!

Get 1:1 Help Now