• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

get/set for Date fields using Apache Beanutils

 
Pat Farrell
Rancher
Posts: 4660
5
Linux Mac OS X VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using the Apache Beanutils code to populate my Bean's fields, and it works great for String valued fields.

But I can't figure out how to use it for the Date type fields.

Google shows links to something called DateLocaleConverter
but I can't find any examples of how it is used.

My code uses Beanutils with:

rMap = ctx.getRequest().getParameterMap();
BeanUtils.populate(this, rMap);

I have no idea what to do to work with a Date field such as

private Date dueDate;
public void setDueDate(xxx);
public xxx getDueDate();

Pointers greatly appreciated.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64196
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Heh heh... adding something to FrontMan 2.0 along these lines.

Here's a sneak peek. It's a work in progress so it's still rough around the edge.

Taken from a class that will do automatic param processing....



 
Pat Farrell
Rancher
Posts: 4660
5
Linux Mac OS X VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Heh heh... adding something to FrontMan 2.0 along these lines


So when will 2.0 be ready for beta testing?

And until then, what do I do to debug it.

I'm getting:

java.lang.IllegalArgumentException: Cannot convert 02/13/10 12:00 AM of type class java.lang.String to class java.util.Date

which makes no sense, as it is in the display of a JSP. The date is properly converted to a String, yet Beanutils seems to be trying to re-convert it to Date
I can't see where from the stackdump
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64196
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pat Farrell wrote:So when will 2.0 be ready for beta testing?

Front Man 2.0 is unfortunately on hold until I finish writing the 2nd edition of jQuery in Action. I'm way behind schedule -- I keep expecting the publisher to send Guido down to break my kneecaps.

java.lang.IllegalArgumentException: Cannot convert 02/13/10 12:00 AM of type class java.lang.String to class java.util.Date


Where's that coming from? All exceptions should be eaten and it'll just return null if anything boofs up. At least that's the intent... as I said, not well tested yet!

So in a sense, you are already beta testing.
 
Pat Farrell
Rancher
Posts: 4660
5
Linux Mac OS X VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:I keep expecting the publisher to send Guido down to break my kneecaps

That's Uncle Guido for you.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64196
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic