aspose file tools*
The moose likes Java in General and the fly likes Date accessor method error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Date accessor method error" Watch "Date accessor method error" New topic
Author

Date accessor method error

Josiah smith
Greenhorn

Joined: Feb 07, 2012
Posts: 8
I am having problems with the accessor method at for the generateRandomDate. The method should return a date in MM/DD/YEAR.
//return new Date(month, day, year); But instead I get a long date? This is causing problems using a dateComparator to sort the queue. Can someone identify what I am missing???



The date comprator that I am using is:

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

Here's your code:


Here's the signature of the constructor you chose, directly from the API documentation:


Do you see your problem?

And by the way your DateComparator has far too much code in it. Date already implements Comparable<Date> so all you need is to use that, along with a bit of generics to get rid of the casts:
Josiah smith
Greenhorn

Joined: Feb 07, 2012
Posts: 8
I am at work and don't have jdk ability right now, but if i used

Will that solve my problem?
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

Josiah smith wrote:I am at work and don't have jdk ability right now, but if i used

Will that solve my problem?


No.

Look more closely at Paul's post. In particular, look closely at the differences he's pointing out between what the Date constructor expects and what you're passing.

Look very closely. Piece by piece. It's blatantly obvious, if you pay attention.
Josiah smith
Greenhorn

Joined: Feb 07, 2012
Posts: 8
Ahh. I think I found it. Should be

???
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7838
    
  21

Josiah smith wrote:Ahh. I think I found it. Should be???

Look again. Hint: The United States is, as far as I know, the only country on the planet to use that insane form of date.

Winston


Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

Josiah smith wrote:Ahh. I think I found it. Should be

???


Isn't that what you already have?

Look again.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Date accessor method error