Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Assigning value of one timestamp to another

 
devaki hanumante
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic