This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes Assigning value of one timestamp to another Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Assigning value of one timestamp to another" Watch "Assigning value of one timestamp to another" New topic
Author

Assigning value of one timestamp to another

devaki hanumante
Greenhorn

Joined: Jan 18, 2009
Posts: 13
I want to assign the value of one timestamp to another in java.
eg:
Timestamp1=timestamp2;

now after that i write the following piece of code
t1.setHours(00);
t1.setMinutes(00);

as a result of this even timestamp2 is getting changed.
is this because they both point to the same object..how do i assign the value of timestamp2 to timestamp1?
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3419
    
  12
devaki hanumante wrote:is this because they both point to the same object

yes
devaki hanumante wrote:how do i assign the value of timestamp2 to timestamp1?

You will need to create a new instance of Timestamp that has the same value as the original instance. Using the clone method is probably the easiest way to do this.

Joanne
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Assigning value of one timestamp to another
 
Similar Threads
Time Stamp values
Convert Object to byte array and array size should be 40
Lost precision in Double variable
unable to retrieve timestamp in my servlet
Convert Object to byte array and array size should be 40