File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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: 32654
    
    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: 12911
    
    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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
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?