Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Calculating days between 2 dates.

 
Al Do
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having a problem with a simple program that calculates the number of days between two dates input. It keeps returning zero and I have no idea why I have tried many different attempts with the daysBetween method.




If any one could shed some light it would be much appreciated.
 
Paul Clapham
Sheriff
Posts: 21293
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I added code tags, so that the code is readable now. (Could you do that yourself in future?)
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Al Do wrote:I am having a problem with a simple program that calculates the number of days between two dates input. It keeps returning zero and I have no idea why I have tried many different attempts with the daysBetween method.


Create a new program from scratch with no GUI stuff, no user input, nothing at all except the code to compute the difference between two hardcoded dates and print it out.


This will make it easier for you to test, debug, and modify your difference calculation code without other distractions, AND it will serve as an SSCCE(⇐click) that will make it easier for folks here to see what you're doing without unnecessary fluff if you need to post again for help.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic