• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Assigning value of one timestamp to another

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic