This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
Hello. I have a problem concerning dates in Java and I have no idea what to use. I have a program which deals with contracts. A new contract can be made on at most 2 years. The user must isert date when contract was made (let's call it "initial") and the date when the contract expires (lets call it "final"). My problem is: what can i use in order to verify if the expiration date inserted by the user is smaller or equal to the date when the contract was made +2 years (final<=initial+2 years)?
Rus Corina wrote:Actually, doesn't work. I work with both java and sql statements, and when trying to define a Date object, it tells me that it is ambiguous whether it is a java Date object or SQL Date object.
Ok, but the reason it doesn't work doesn't have anything to do with the code that Zandis posted.
It's because you have two classes both named Date: java.util.Date and java.sql.Date. If you import both java.util.* and java.sql.* then Java doesn't know which one you mean if you use class Date. You should spell out the entire class name in your code, like this: