• Post Reply Bookmark Topic Watch Topic
  • New Topic

Calendar running away  RSS feed

 
Paul Mrozik
Ranch Hand
Posts: 117
Chrome Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I needed to insert dates and time into my database. Then I noticed something strange, the time entered by the user was not exactly the time that shows up in the database. And so I wrote this program:



And found a solution, but it still doesn't answer the question why time continues to run for calendarTwo. Does it reference a system timer of some sort?

 
Matthew Brown
Bartender
Posts: 4568
9
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The value of a Calendar shouldn't change except when you change it. What output are you getting that's surprising you?

(One thing that I do notice is that you're setting and printing MILLISECOND, but not SECOND).
 
Paul Mrozik
Ranch Hand
Posts: 117
Chrome Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Matthew. Of course you're right.

It's good that you pointed out that I failed to set and print SECOND. In my program(not this one) I noticed I'd made the mistake of using the same reference name twice to set values and so I was just getting the current time for the second object.

Problem solved.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!