This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
Rajesh Khan wrote:So eclipse tells me that date type is depricated.
No it didn't, because Date is not deprecated.
So i started using Calendar
Date and Calendar serve different roles, and are often used together. A Date represents an instant in time, without regard to human notations like years, months, time zones, etc. A Calendar represents a particular human convention for naming that instant in time.
Because you're not setting it. The error messages don't lie. Since I can't see your entire code and don't know which line it's talking about, my guess it that you're making the very common error of having a local variable that hides a member:
In this class, the setX method does not set our x member variable.
Are you sure it's the date variable (Note: variable, not object) which is not being set? I can't see the line it's complaining about, but perhaps you're misinterpreting the error message and it's a different variable that's not set.
And why is it that you think mydate will not be null?
(Also, it will be easier for others to read your code, and thus you'll get better help, if you follow Java's naming conventions. Class names start with uppercase and use camel case. Methods and variables start with lowercase and use camel case:
This doesn't help us, since we don't know which line is #23 in your code. You have to clearly indicate which line it is, or else paste in the exact code that you compiled so that the forum's line numbers will match your own.
Joined: Oct 16, 2011
Calendar is not a primitive type need to create an instance of it first.
Although I agree your information has come in bits and spurts and is still incomplete, I think your problem is liable to be "private Calendar mydate;" because you do not show any code that initializes mydate; then setmydate attempts to dereference it, producing a null pointer. Somewhere some code has to do "mydate = new Calendar();" or its equivalent.