avogrado heisenburg wrote:Should I repost so I can shorten the code?
Yes. Just reply here with new code that has no GUI stuff in it, no user input, just an attempt at getting Thanksgiving's date some hardcoded year, like this year.
And what do you mean to get rid of the date constructor?
I mean a Date object has no concept of Year, Month, Day, etc. It's just a number of milliseconds since a starting point. You shouldn't use the constructor that takes those parameters. As you can see from the docs, it's been deprecated.
I heard yo must use SimpleDateFormat or something like that in order to convert the date to a string.
If you want to convert a Date to a String or a String to a Date, yes, you use SimpleDateFormat. But if you're not taking in a String representation of a Date, such as "10/31/2012", and are just taking in the year, then you don't need that. You'll need to use a Calendar to do the manipulations anyway, so you can just set the Calendar's year to the one provided before starting the fiddling.
The problem is that I'm printing out the reference (memory location or something like that).
You probably tried to print the SDF, rather than calling it's appropriate method to get the String representation of the date.
But I have no Idea how to use the SimpleDateFormat. Can you help me? Thank you
Did you try reading its documentation? Or googling for
java SimpleDateFormat example?