• 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

Calendar running away

 
Ranch Hand
Posts: 117
Mac Chrome Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?

 
Bartender
Posts: 4568
9
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Mac Chrome Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic