This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Timestamp advanced 4 hours Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Timestamp advanced 4 hours " Watch "Timestamp advanced 4 hours " New topic
Author

Timestamp advanced 4 hours

majid nakit
Ranch Hand

Joined: Jun 26, 2001
Posts: 160
Hi,
Timestamp ts = new Timestamp(new Date().getTime());

I am displaying the Timestamp , but instead of showing :

Last Update: 2007-10-09 13:29:32.0

it shows
Last Update: 2007-10-09 17:29:32.0

can you please help me.
thanks
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

Looks like a timezone problem.


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
majid nakit
Ranch Hand

Joined: Jun 26, 2001
Posts: 160
Hi,
I am living here in Est Cost, but still get the UTC time, 4 hours ahead.
how to set the time to be my local time.
thanks
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32675
    
    4
Check which time zone you are using
See whether that helps at all.
majid nakit
Ranch Hand

Joined: Jun 26, 2001
Posts: 160
Hi,
America/New_York

wich is the correct time for Boston, but when I run my project in Netbeans, I got 4 hours ahead.
Kamal Ahmed
Ranch Hand

Joined: Feb 15, 2005
Posts: 90
Where did you import Timestamp from?
Jesper de Jong
Java Cowboy
Bartender

Joined: Aug 16, 2005
Posts: 12921
    
    3

Originally posted by majid nakit:
I am displaying the Timestamp , ...

How are you displaying the timestamp? You can use a DateFormat object to format a date any way you like, and set the timezone on the DateFormat object to show it in a specific timezone. For example:


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Timestamp advanced 4 hours
 
Similar Threads
Handling concurrent updates using JDBC
timezone conversion using DST
Retriving data from a log file
Problem computing time based on TimeZones
values change unexpectedly due to threading issue?