Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Comparing dates using GregorianCalendar

 
Chan Ag
Rancher
Posts: 1089
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jeff,

I've also tried to work on a similar problem in the past ( I'm also new to java and working on demo programs to get acquainted with java APIs). I passed two Date objects to a method that would call getTime() method on the two date objects and subtract the two times in milliseconds and then divide the result by 3600*24*1000 to compute the number of days. But I don't like that approach. I wanna also try the solution proposed by you. But I don't know how to create a GregorianCalendar corresponding to now. Could you please explain how to do that too.

Thanks so much.

Regards...

[MODERATOR COMMENT: Split from http://www.coderanch.com/t/594881/java/java/Comparing-dates-Java]
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chan Go wrote:I don't know how to create a GregorianCalendar corresponding to now.


Welcome to the Ranch!

If you look at the javadocs for java.util.GregorianCalendar, I think you'll find it's obvious.
 
Chan Ag
Rancher
Posts: 1089
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Jeff.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic