aspose file tools*
The moose likes Beginning Java and the fly likes Dates comparison with Calendar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Dates comparison with Calendar" Watch "Dates comparison with Calendar" New topic
Author

Dates comparison with Calendar

Madhu Sudhana
Ranch Hand

Joined: Apr 16, 2006
Posts: 127

Hi
in the above program I am trying to compare a date with current date.
if I give input date like(08/31/2009) its showing the input date is after the currect date.

I am not able to understand the problem.could you help me


"And the trouble is, if you don't risk anything, you risk even more." -- Erica Jong.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 13875
    
  10

Originally posted by Madhu Sudhana:
in the above program I am trying to compare a date with current date.
if I give input date like(08/31/2009) its showing the input date is after the currect date.

I am not able to understand the problem.could you help me

So, 31 August 2009 is in the future, so it is correct that it says it is after the current date.

Can you explain more clearly what you don't understand?


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Madhu Sudhana
Ranch Hand

Joined: Apr 16, 2006
Posts: 127
todays date is 08/31/2007. then It should not be future,right ?
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
assuming 08/31/2009 is a typo, in java terms 31 August is 07/31/2007
months are 0-based
Vaibhav Goel
Ranch Hand

Joined: Jul 05, 2007
Posts: 40
Hi,
I have seen your code. There was an error in the line beginning with "input.set" part of your code. You forget that input is an instance of Calender and its arguments must contain primitive integers and not Integer objects.
First remove your error by writing

Secondly, write properly what is your problem regarding current date.

What I understand with your problem is; you want to compare user input date with the current system date.

Tell me whether the user-input date could be less than system date or not.

Note: It might be possible in future that I can't respond soon due to time-shortage. But if I have time, then surely I visit javaranch.
Regards,
Vaibhav Goel
 
 
subject: Dates comparison with Calendar
 
Similar Threads
Any Alternative for this CODE !!!!!!
Gregorian Calandar
Adding seconds to time
Convert the String to date format
Date Generation