Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • Is this homework? are you required not to use external libraries? Commented Feb 20, 2012 at 18:06
  • See stackoverflow.com/questions/439903/… - you don't have to write this code yourself. Commented Feb 20, 2012 at 18:07
  • It would be better to store only seconds and calculate hours and minutes on demand. Otherwise, arithmetic will be harder. Also, you need range validation. Commented Feb 20, 2012 at 18:07
  • docs.oracle.com/javase/1.4.2/docs/api/java/sql/Timestamp.html Commented Feb 20, 2012 at 18:07
  • See Peter's answer. If you truly, truly want to make your own class it is indeed much better to just store it in (m)seconds and calculate everything else. You're going to introduce a lot of bugs otherwise. Commented Feb 20, 2012 at 18:09