• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Date accessor method error

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:

 
Sheriff
Posts: 28385
99
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am at work and don't have jdk ability right now, but if i used

Will that solve my problem?
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ahh. I think I found it. Should be

???
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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

???



Isn't that what you already have?

Look again.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic