aspose file tools*
The moose likes Beginning Java and the fly likes Timestamp advanced 4 hours Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
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: 161
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: 19543
    
  16

Looks like a timezone problem.


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

Joined: Jun 26, 2001
Posts: 161
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: 36508
    
  16
Check which time zone you are using
See whether that helps at all.
majid nakit
Ranch Hand

Joined: Jun 26, 2001
Posts: 161
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: 91
Where did you import Timestamp from?
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 13875
    
  10

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://aspose.com/file-tools
 
subject: Timestamp advanced 4 hours
 
Similar Threads
Retriving data from a log file
Handling concurrent updates using JDBC
values change unexpectedly due to threading issue?
Problem computing time based on TimeZones
timezone conversion using DST