You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Andreas Joseph Krogh <an...@officenet.no> on 2008/12/16 23:09:52 UTC

Struts2 and joda-time

Hi all.
I'm trying trunk now with a field in my domain-object (User) with a property of type DateTime:

private DateTime birthDate;

Then I have a datepicker in my JSP operation on this property:
<sx:datetimepicker name="user.birthDate" displayFormat="yyyy.MM.dd"/>
And it renders the date correctly

The problem is that it's failing when trying to save the form:

2008-12-16 23:01:14,874 DEBUG [UserAction.java:100] : In prepare()
ognl.MethodFailedException: Method "setBirthDate" failed for object no.officenet.mvctest.struts2.backend.model.User@cca81013 [java.lang.NoSuchMethodException: setBirthDate([Ljava.lang.String;)]

Is this supposed to work? I thought so, reading this:
The comment in WW-2476 saying that "This was resolved as part of XW-473", what does it actually mean?

-- 
Andreas Joseph Krogh <an...@officenet.no>
Senior Software Developer / CEO
------------------------+---------------------------------------------+
OfficeNet AS            | The most difficult thing in the world is to |
Karenslyst Allé 11      | know how to do a thing and to watch         |
PO. Box 529 Skøyen      | somebody else doing it wrong, without       |
0214 Oslo               | comment.                                    |
NORWAY                  |                                             |
Tlf:    +47 24 15 38 90 |                                             |
Fax:    +47 24 15 38 91 |                                             |
Mobile: +47 909  56 963 |                                             |
------------------------+---------------------------------------------+

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Struts2 and joda-time

Posted by Andreas Joseph Krogh <an...@officenet.no>.
On Tuesday 16 December 2008 23:36:50 Musachy Barroso wrote:
> > Previously I've created container-objects to wrap joda-classes, which works but shouldn't be necessary. I kind of hoped that Struts-2 in its most modern form (trunk) included converters for the most common object-types. I think, for what it's worth, the ticket is missleading and that it should be commented somewhere that Struts-2.1 will not support joda-time.
> 
> There are a bunch of alternatives to this
> 
> 1. define a converter in your app
> 2. write a plugin that has a converter
> 3. write a patch to xwork XWorkBasicConverter
> 
> I kind of doubt that #3 would go thru, as we avoid having
> dependencies, as the plague. #2 sounds reasonable.


Isn't #2 what this is about?
https://issues.apache.org/struts/browse/WW-2476

What really confused me was that this issue has status "Resolved" and really isn't resolved at all. The attached files are not in trunk. A comment saying something like "This could be used to write a plugin as we don't want to introduce an external dependency to joda-time" and status="Won't fix" would be nice IMHO.

-- 
Andreas Joseph Krogh <an...@officenet.no>
Senior Software Developer / CEO
------------------------+---------------------------------------------+
OfficeNet AS            | The most difficult thing in the world is to |
Karenslyst Allé 11      | know how to do a thing and to watch         |
PO. Box 529 Skøyen      | somebody else doing it wrong, without       |
0214 Oslo               | comment.                                    |
NORWAY                  |                                             |
Tlf:    +47 24 15 38 90 |                                             |
Fax:    +47 24 15 38 91 |                                             |
Mobile: +47 909  56 963 |                                             |
------------------------+---------------------------------------------+

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Struts2 and joda-time

Posted by Miguel <mi...@gmail.com>.
I use yoda time, also with Hibernate.
Once I found a patch (don't remember where), but as far as i have used
it, i think it works.

package funala.web.typeconverter;
public class Iso8601DateTypeConverter extends StrutsTypeConverter {...}

Try it, It does what it is supposed to do (reading the code), i have
used it, but i don't know if I'm using it properly


Si quieres ser más positivo, pierde un electrón
Miguel Ruiz Velasco S.



On Tue, Dec 16, 2008 at 16:49, Dave Newton <ne...@yahoo.com> wrote:
> --- On Tue, 12/16/08, Andreas Joseph Krogh wrote:
>> Anyone else needing this, or am I in some kind of
>> joda-cult here in Norway?
>
> I've used it, but all the places I've consulted at use java.util.Date. Yours is the first request for it that I know of, and I follow the user group fairly closely.
>
> Obviously writing your own local converter would be the quickest (an hour?) but a plugin would be cooler.
>
> One potential issue is that it might be more difficult than necessary to have multiple plugin-supplied type converters--doesn't XW look for a single conversion properties file in the CP root?
>
> It'd be better if it did this some way that would allow plugins to supply their own set of converters somehow.
>
> Dave
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Struts2 and joda-time

Posted by Musachy Barroso <mu...@gmail.com>.
> He he, we know different people it seems:-) Anyway, it's not like the API of joda-time changes very often, so I assume it's practically a one-timer. But, I see that this doesn't ich very much, obviously, among the core-developers, and hence doesn't get scratched.
>

use the force you must. Or was that Yoda?

musachy

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Struts2 and joda-time

Posted by Andreas Joseph Krogh <an...@officenet.no>.
On Tuesday 16 December 2008 23:49:51 Dave Newton wrote:
> --- On Tue, 12/16/08, Andreas Joseph Krogh wrote:
> > Anyone else needing this, or am I in some kind of 
> > joda-cult here in Norway?
> 
> I've used it, but all the places I've consulted at use java.util.Date. Yours is the first request for it that I know of, and I follow the user group fairly closely.
> 
> Obviously writing your own local converter would be the quickest (an hour?) but a plugin would be cooler.
> 
> One potential issue is that it might be more difficult than necessary to have multiple plugin-supplied type converters--doesn't XW look for a single conversion properties file in the CP root?
> 
> It'd be better if it did this some way that would allow plugins to supply their own set of converters somehow.

I don't know much about the details of plugins, but maybe I'll find some time this x-mas checking things out.

This should be of interest for any framework-developer:
http://today.java.net/pub/a/today/2008/09/18/jsr-310-new-java-date-time-api.html
JSR-310, based on joda-time.

-- 
Andreas Joseph Krogh <an...@officenet.no>
Senior Software Developer / CEO
------------------------+---------------------------------------------+
OfficeNet AS            | The most difficult thing in the world is to |
Karenslyst Allé 11      | know how to do a thing and to watch         |
PO. Box 529 Skøyen      | somebody else doing it wrong, without       |
0214 Oslo               | comment.                                    |
NORWAY                  |                                             |
Tlf:    +47 24 15 38 90 |                                             |
Fax:    +47 24 15 38 91 |                                             |
Mobile: +47 909  56 963 |                                             |
------------------------+---------------------------------------------+

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Struts2 and joda-time

Posted by Dave Newton <ne...@yahoo.com>.
--- On Tue, 12/16/08, Andreas Joseph Krogh wrote:
> Anyone else needing this, or am I in some kind of 
> joda-cult here in Norway?

I've used it, but all the places I've consulted at use java.util.Date. Yours is the first request for it that I know of, and I follow the user group fairly closely.

Obviously writing your own local converter would be the quickest (an hour?) but a plugin would be cooler.

One potential issue is that it might be more difficult than necessary to have multiple plugin-supplied type converters--doesn't XW look for a single conversion properties file in the CP root?

It'd be better if it did this some way that would allow plugins to supply their own set of converters somehow.

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Struts2 and joda-time

Posted by Andreas Joseph Krogh <an...@officenet.no>.
On Tuesday 16 December 2008 23:30:59 Martin Cooper wrote:
> On Tue, Dec 16, 2008 at 2:23 PM, Andreas Joseph Krogh
> <an...@officenet.no>wrote:
> 
> > On Tuesday 16 December 2008 23:14:50 Musachy Barroso wrote:
> > > It doesn't mean that it will convert from string to a joda object, it
> > > means that it will convert a string in ISO 8601 format, to a Date
> > > object. The patch in that ticket used joda lib to create the ISO 8601,
> > > if I don't remember wrong.
> >
> > Ok, so you're saying that Struts2 (even in trunk) is unable to handle
> > joda-time dates out of the box? That's a pitty. In 2008, is anyone actually
> > using pure java.util.Date anymore?
> 
> 
> I was wondering the opposite - are enough people using Joda Time to make it
> worth the support / time / energy in S2? Everyone I know is, in fact, using
> java.util.Date.

He he, we know different people it seems:-) Anyway, it's not like the API of joda-time changes very often, so I assume it's practically a one-timer. But, I see that this doesn't ich very much, obviously, among the core-developers, and hence doesn't get scratched.

Anyone else needing this, or am I in some kind of joda-cult here in Norway?

-- 
Andreas Joseph Krogh <an...@officenet.no>
Senior Software Developer / CEO
------------------------+---------------------------------------------+
OfficeNet AS            | The most difficult thing in the world is to |
Karenslyst Allé 11      | know how to do a thing and to watch         |
PO. Box 529 Skøyen      | somebody else doing it wrong, without       |
0214 Oslo               | comment.                                    |
NORWAY                  |                                             |
Tlf:    +47 24 15 38 90 |                                             |
Fax:    +47 24 15 38 91 |                                             |
Mobile: +47 909  56 963 |                                             |
------------------------+---------------------------------------------+

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Struts2 and joda-time

Posted by Ronny Løvtangen <ro...@lovtangen.com>.
Be aware that new DateTime(null) results in "now". (go figure..)
So you may want to check the parameter 'Date start' for null.

Ronny

On Dec 19, 2008, at 5:58 PM, Miguel wrote:

> Something you can allways do, is to define a parallel set of
> getter/setter in your bean with type java.util.Date that internally
> does the conversion.
>
> 	public Date getStartDate() {
> 		return start.toDate();
> 	}
>
> 	public void setStartDate(Date start) {
> 		this.start = new DateTime( start) ;
> 	}
>
>
> Si quieres ser más positivo, pierde un electrón
> Miguel Ruiz Velasco S.
>
>
>
> On Wed, Dec 17, 2008 at 09:46, Brian Pontarelli  
> <br...@pontarelli.com> wrote:
>> Date is pretty much deprecated except for a way to carry a long  
>> primitive
>> around because of the TZ and conversions it lacks. It fails in some  
>> cases
>> and most of the core API on Date is deprecated. Most folks should  
>> be using
>> Calendar for date and time correctness if they don't want to use  
>> Joda and
>> stick with the JDK classes. Calendar however is very clunky and  
>> mutable.
>> Therefore, most people I know that need to internationalize or  
>> localize use
>> Joda because it is correct, simple and immutable. Also, something  
>> very
>> similar to the Joda date/time API is probably going to be in Java  
>> 8.0 or
>> something like that via JSR 310, unless it gets squashed or no one  
>> pushes it
>> forward. Even still, Joda is the benchmark these days for a date/ 
>> time API.
>>
>> -bp
>>
>> On Dec 16, 2008, at 3:30 PM, Martin Cooper wrote:
>>
>>> On Tue, Dec 16, 2008 at 2:23 PM, Andreas Joseph Krogh
>>> <an...@officenet.no>wrote:
>>>
>>>> On Tuesday 16 December 2008 23:14:50 Musachy Barroso wrote:
>>>>>
>>>>> It doesn't mean that it will convert from string to a joda  
>>>>> object, it
>>>>> means that it will convert a string in ISO 8601 format, to a Date
>>>>> object. The patch in that ticket used joda lib to create the ISO  
>>>>> 8601,
>>>>> if I don't remember wrong.
>>>>
>>>> Ok, so you're saying that Struts2 (even in trunk) is unable to  
>>>> handle
>>>> joda-time dates out of the box? That's a pitty. In 2008, is anyone
>>>> actually
>>>> using pure java.util.Date anymore?
>>>
>>>
>>> I was wondering the opposite - are enough people using Joda Time  
>>> to make
>>> it
>>> worth the support / time / energy in S2? Everyone I know is, in  
>>> fact,
>>> using
>>> java.util.Date.
>>>
>>> --
>>> Martin Cooper
>>>
>>>
>>>
>>>>
>>>>
>>>> Previously I've created container-objects to wrap joda-classes,  
>>>> which
>>>> works
>>>> but shouldn't be necessary. I kind of hoped that Struts-2 in its  
>>>> most
>>>> modern
>>>> form (trunk) included converters for the most common object- 
>>>> types. I
>>>> think,
>>>> for what it's worth, the ticket is missleading and that it should  
>>>> be
>>>> commented somewhere that Struts-2.1 will not support joda-time.
>>>>
>>>> I know this sounds kind of rant-ish, but there are so many good  
>>>> things
>>>> about Struts2 that missing out-of-the-box joda-support is kind of  
>>>> hard to
>>>> swallow...
>>>>
>>>> --
>>>> Andreas Joseph Krogh <an...@officenet.no>
>>>> Senior Software Developer / CEO
>>>> ------------------------ 
>>>> +---------------------------------------------+
>>>> OfficeNet AS            | The most difficult thing in the world  
>>>> is to |
>>>> Karenslyst Allé 11      | know how to do a thing and to  
>>>> watch         |
>>>> PO. Box 529 Skøyen      | somebody else doing it wrong,  
>>>> without       |
>>>> 0214 Oslo               |  
>>>> comment.                                    |
>>>> NORWAY                   
>>>> |                                             |
>>>> Tlf:    +47 24 15 38 90  
>>>> |                                             |
>>>> Fax:    +47 24 15 38 91  
>>>> |                                             |
>>>> Mobile: +47 909  56 963  
>>>> |                                             |
>>>> ------------------------ 
>>>> +---------------------------------------------+
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>>>> For additional commands, e-mail: dev-help@struts.apache.org
>>>>
>>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>> For additional commands, e-mail: dev-help@struts.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Struts2 and joda-time

Posted by Brian Pontarelli <br...@pontarelli.com>.
Those will need NPE checks by the way.

:)

-bp


On Dec 19, 2008, at 9:58 AM, Miguel wrote:

> Something you can allways do, is to define a parallel set of
> getter/setter in your bean with type java.util.Date that internally
> does the conversion.
>
> 	public Date getStartDate() {
> 		return start.toDate();
> 	}
>
> 	public void setStartDate(Date start) {
> 		this.start = new DateTime( start) ;
> 	}
>
>
> Si quieres ser más positivo, pierde un electrón
> Miguel Ruiz Velasco S.
>
>
>
> On Wed, Dec 17, 2008 at 09:46, Brian Pontarelli  
> <br...@pontarelli.com> wrote:
>> Date is pretty much deprecated except for a way to carry a long  
>> primitive
>> around because of the TZ and conversions it lacks. It fails in some  
>> cases
>> and most of the core API on Date is deprecated. Most folks should  
>> be using
>> Calendar for date and time correctness if they don't want to use  
>> Joda and
>> stick with the JDK classes. Calendar however is very clunky and  
>> mutable.
>> Therefore, most people I know that need to internationalize or  
>> localize use
>> Joda because it is correct, simple and immutable. Also, something  
>> very
>> similar to the Joda date/time API is probably going to be in Java  
>> 8.0 or
>> something like that via JSR 310, unless it gets squashed or no one  
>> pushes it
>> forward. Even still, Joda is the benchmark these days for a date/ 
>> time API.
>>
>> -bp
>>
>> On Dec 16, 2008, at 3:30 PM, Martin Cooper wrote:
>>
>>> On Tue, Dec 16, 2008 at 2:23 PM, Andreas Joseph Krogh
>>> <an...@officenet.no>wrote:
>>>
>>>> On Tuesday 16 December 2008 23:14:50 Musachy Barroso wrote:
>>>>>
>>>>> It doesn't mean that it will convert from string to a joda  
>>>>> object, it
>>>>> means that it will convert a string in ISO 8601 format, to a Date
>>>>> object. The patch in that ticket used joda lib to create the ISO  
>>>>> 8601,
>>>>> if I don't remember wrong.
>>>>
>>>> Ok, so you're saying that Struts2 (even in trunk) is unable to  
>>>> handle
>>>> joda-time dates out of the box? That's a pitty. In 2008, is anyone
>>>> actually
>>>> using pure java.util.Date anymore?
>>>
>>>
>>> I was wondering the opposite - are enough people using Joda Time  
>>> to make
>>> it
>>> worth the support / time / energy in S2? Everyone I know is, in  
>>> fact,
>>> using
>>> java.util.Date.
>>>
>>> --
>>> Martin Cooper
>>>
>>>
>>>
>>>>
>>>>
>>>> Previously I've created container-objects to wrap joda-classes,  
>>>> which
>>>> works
>>>> but shouldn't be necessary. I kind of hoped that Struts-2 in its  
>>>> most
>>>> modern
>>>> form (trunk) included converters for the most common object- 
>>>> types. I
>>>> think,
>>>> for what it's worth, the ticket is missleading and that it should  
>>>> be
>>>> commented somewhere that Struts-2.1 will not support joda-time.
>>>>
>>>> I know this sounds kind of rant-ish, but there are so many good  
>>>> things
>>>> about Struts2 that missing out-of-the-box joda-support is kind of  
>>>> hard to
>>>> swallow...
>>>>
>>>> --
>>>> Andreas Joseph Krogh <an...@officenet.no>
>>>> Senior Software Developer / CEO
>>>> ------------------------ 
>>>> +---------------------------------------------+
>>>> OfficeNet AS            | The most difficult thing in the world  
>>>> is to |
>>>> Karenslyst Allé 11      | know how to do a thing and to  
>>>> watch         |
>>>> PO. Box 529 Skøyen      | somebody else doing it wrong,  
>>>> without       |
>>>> 0214 Oslo               |  
>>>> comment.                                    |
>>>> NORWAY                   
>>>> |                                             |
>>>> Tlf:    +47 24 15 38 90  
>>>> |                                             |
>>>> Fax:    +47 24 15 38 91  
>>>> |                                             |
>>>> Mobile: +47 909  56 963  
>>>> |                                             |
>>>> ------------------------ 
>>>> +---------------------------------------------+
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>>>> For additional commands, e-mail: dev-help@struts.apache.org
>>>>
>>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>> For additional commands, e-mail: dev-help@struts.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Struts2 and joda-time

Posted by Miguel <mi...@gmail.com>.
Something you can allways do, is to define a parallel set of
getter/setter in your bean with type java.util.Date that internally
does the conversion.

	public Date getStartDate() {
		return start.toDate();
	}

	public void setStartDate(Date start) {
		this.start = new DateTime( start) ;
	}


Si quieres ser más positivo, pierde un electrón
Miguel Ruiz Velasco S.



On Wed, Dec 17, 2008 at 09:46, Brian Pontarelli <br...@pontarelli.com> wrote:
> Date is pretty much deprecated except for a way to carry a long primitive
> around because of the TZ and conversions it lacks. It fails in some cases
> and most of the core API on Date is deprecated. Most folks should be using
> Calendar for date and time correctness if they don't want to use Joda and
> stick with the JDK classes. Calendar however is very clunky and mutable.
> Therefore, most people I know that need to internationalize or localize use
> Joda because it is correct, simple and immutable. Also, something very
> similar to the Joda date/time API is probably going to be in Java 8.0 or
> something like that via JSR 310, unless it gets squashed or no one pushes it
> forward. Even still, Joda is the benchmark these days for a date/time API.
>
> -bp
>
> On Dec 16, 2008, at 3:30 PM, Martin Cooper wrote:
>
>> On Tue, Dec 16, 2008 at 2:23 PM, Andreas Joseph Krogh
>> <an...@officenet.no>wrote:
>>
>>> On Tuesday 16 December 2008 23:14:50 Musachy Barroso wrote:
>>>>
>>>> It doesn't mean that it will convert from string to a joda object, it
>>>> means that it will convert a string in ISO 8601 format, to a Date
>>>> object. The patch in that ticket used joda lib to create the ISO 8601,
>>>> if I don't remember wrong.
>>>
>>> Ok, so you're saying that Struts2 (even in trunk) is unable to handle
>>> joda-time dates out of the box? That's a pitty. In 2008, is anyone
>>> actually
>>> using pure java.util.Date anymore?
>>
>>
>> I was wondering the opposite - are enough people using Joda Time to make
>> it
>> worth the support / time / energy in S2? Everyone I know is, in fact,
>> using
>> java.util.Date.
>>
>> --
>> Martin Cooper
>>
>>
>>
>>>
>>>
>>> Previously I've created container-objects to wrap joda-classes, which
>>> works
>>> but shouldn't be necessary. I kind of hoped that Struts-2 in its most
>>> modern
>>> form (trunk) included converters for the most common object-types. I
>>> think,
>>> for what it's worth, the ticket is missleading and that it should be
>>> commented somewhere that Struts-2.1 will not support joda-time.
>>>
>>> I know this sounds kind of rant-ish, but there are so many good things
>>> about Struts2 that missing out-of-the-box joda-support is kind of hard to
>>> swallow...
>>>
>>> --
>>> Andreas Joseph Krogh <an...@officenet.no>
>>> Senior Software Developer / CEO
>>> ------------------------+---------------------------------------------+
>>> OfficeNet AS            | The most difficult thing in the world is to |
>>> Karenslyst Allé 11      | know how to do a thing and to watch         |
>>> PO. Box 529 Skøyen      | somebody else doing it wrong, without       |
>>> 0214 Oslo               | comment.                                    |
>>> NORWAY                  |                                             |
>>> Tlf:    +47 24 15 38 90 |                                             |
>>> Fax:    +47 24 15 38 91 |                                             |
>>> Mobile: +47 909  56 963 |                                             |
>>> ------------------------+---------------------------------------------+
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: dev-help@struts.apache.org
>>>
>>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Struts2 and joda-time

Posted by Brian Pontarelli <br...@pontarelli.com>.
Date is pretty much deprecated except for a way to carry a long  
primitive around because of the TZ and conversions it lacks. It fails  
in some cases and most of the core API on Date is deprecated. Most  
folks should be using Calendar for date and time correctness if they  
don't want to use Joda and stick with the JDK classes. Calendar  
however is very clunky and mutable. Therefore, most people I know that  
need to internationalize or localize use Joda because it is correct,  
simple and immutable. Also, something very similar to the Joda date/ 
time API is probably going to be in Java 8.0 or something like that  
via JSR 310, unless it gets squashed or no one pushes it forward. Even  
still, Joda is the benchmark these days for a date/time API.

-bp

On Dec 16, 2008, at 3:30 PM, Martin Cooper wrote:

> On Tue, Dec 16, 2008 at 2:23 PM, Andreas Joseph Krogh
> <an...@officenet.no>wrote:
>
>> On Tuesday 16 December 2008 23:14:50 Musachy Barroso wrote:
>>> It doesn't mean that it will convert from string to a joda object,  
>>> it
>>> means that it will convert a string in ISO 8601 format, to a Date
>>> object. The patch in that ticket used joda lib to create the ISO  
>>> 8601,
>>> if I don't remember wrong.
>>
>> Ok, so you're saying that Struts2 (even in trunk) is unable to handle
>> joda-time dates out of the box? That's a pitty. In 2008, is anyone  
>> actually
>> using pure java.util.Date anymore?
>
>
> I was wondering the opposite - are enough people using Joda Time to  
> make it
> worth the support / time / energy in S2? Everyone I know is, in  
> fact, using
> java.util.Date.
>
> --
> Martin Cooper
>
>
>
>>
>>
>> Previously I've created container-objects to wrap joda-classes,  
>> which works
>> but shouldn't be necessary. I kind of hoped that Struts-2 in its  
>> most modern
>> form (trunk) included converters for the most common object-types.  
>> I think,
>> for what it's worth, the ticket is missleading and that it should be
>> commented somewhere that Struts-2.1 will not support joda-time.
>>
>> I know this sounds kind of rant-ish, but there are so many good  
>> things
>> about Struts2 that missing out-of-the-box joda-support is kind of  
>> hard to
>> swallow...
>>
>> --
>> Andreas Joseph Krogh <an...@officenet.no>
>> Senior Software Developer / CEO
>> ------------------------ 
>> +---------------------------------------------+
>> OfficeNet AS            | The most difficult thing in the world is  
>> to |
>> Karenslyst Allé 11      | know how to do a thing and to  
>> watch         |
>> PO. Box 529 Skøyen      | somebody else doing it wrong,  
>> without       |
>> 0214 Oslo               |  
>> comment.                                    |
>> NORWAY                   
>> |                                             |
>> Tlf:    +47 24 15 38 90  
>> |                                             |
>> Fax:    +47 24 15 38 91  
>> |                                             |
>> Mobile: +47 909  56 963  
>> |                                             |
>> ------------------------ 
>> +---------------------------------------------+
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>> For additional commands, e-mail: dev-help@struts.apache.org
>>
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Struts2 and joda-time

Posted by Martin Cooper <ma...@apache.org>.
On Tue, Dec 16, 2008 at 2:23 PM, Andreas Joseph Krogh
<an...@officenet.no>wrote:

> On Tuesday 16 December 2008 23:14:50 Musachy Barroso wrote:
> > It doesn't mean that it will convert from string to a joda object, it
> > means that it will convert a string in ISO 8601 format, to a Date
> > object. The patch in that ticket used joda lib to create the ISO 8601,
> > if I don't remember wrong.
>
> Ok, so you're saying that Struts2 (even in trunk) is unable to handle
> joda-time dates out of the box? That's a pitty. In 2008, is anyone actually
> using pure java.util.Date anymore?


I was wondering the opposite - are enough people using Joda Time to make it
worth the support / time / energy in S2? Everyone I know is, in fact, using
java.util.Date.

--
Martin Cooper



>
>
> Previously I've created container-objects to wrap joda-classes, which works
> but shouldn't be necessary. I kind of hoped that Struts-2 in its most modern
> form (trunk) included converters for the most common object-types. I think,
> for what it's worth, the ticket is missleading and that it should be
> commented somewhere that Struts-2.1 will not support joda-time.
>
> I know this sounds kind of rant-ish, but there are so many good things
> about Struts2 that missing out-of-the-box joda-support is kind of hard to
> swallow...
>
> --
> Andreas Joseph Krogh <an...@officenet.no>
> Senior Software Developer / CEO
> ------------------------+---------------------------------------------+
> OfficeNet AS            | The most difficult thing in the world is to |
> Karenslyst Allé 11      | know how to do a thing and to watch         |
> PO. Box 529 Skøyen      | somebody else doing it wrong, without       |
> 0214 Oslo               | comment.                                    |
> NORWAY                  |                                             |
> Tlf:    +47 24 15 38 90 |                                             |
> Fax:    +47 24 15 38 91 |                                             |
> Mobile: +47 909  56 963 |                                             |
> ------------------------+---------------------------------------------+
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>

Re: Struts2 and joda-time

Posted by Musachy Barroso <mu...@gmail.com>.
> Previously I've created container-objects to wrap joda-classes, which works but shouldn't be necessary. I kind of hoped that Struts-2 in its most modern form (trunk) included converters for the most common object-types. I think, for what it's worth, the ticket is missleading and that it should be commented somewhere that Struts-2.1 will not support joda-time.

There are a bunch of alternatives to this

1. define a converter in your app
2. write a plugin that has a converter
3. write a patch to xwork XWorkBasicConverter

I kind of doubt that #3 would go thru, as we avoid having
dependencies, as the plague. #2 sounds reasonable.

musachy
-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Struts2 and joda-time

Posted by Andreas Joseph Krogh <an...@officenet.no>.
On Tuesday 16 December 2008 23:14:50 Musachy Barroso wrote:
> It doesn't mean that it will convert from string to a joda object, it
> means that it will convert a string in ISO 8601 format, to a Date
> object. The patch in that ticket used joda lib to create the ISO 8601,
> if I don't remember wrong.

Ok, so you're saying that Struts2 (even in trunk) is unable to handle joda-time dates out of the box? That's a pitty. In 2008, is anyone actually using pure java.util.Date anymore?

Previously I've created container-objects to wrap joda-classes, which works but shouldn't be necessary. I kind of hoped that Struts-2 in its most modern form (trunk) included converters for the most common object-types. I think, for what it's worth, the ticket is missleading and that it should be commented somewhere that Struts-2.1 will not support joda-time.

I know this sounds kind of rant-ish, but there are so many good things about Struts2 that missing out-of-the-box joda-support is kind of hard to swallow...

-- 
Andreas Joseph Krogh <an...@officenet.no>
Senior Software Developer / CEO
------------------------+---------------------------------------------+
OfficeNet AS            | The most difficult thing in the world is to |
Karenslyst Allé 11      | know how to do a thing and to watch         |
PO. Box 529 Skøyen      | somebody else doing it wrong, without       |
0214 Oslo               | comment.                                    |
NORWAY                  |                                             |
Tlf:    +47 24 15 38 90 |                                             |
Fax:    +47 24 15 38 91 |                                             |
Mobile: +47 909  56 963 |                                             |
------------------------+---------------------------------------------+

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Struts2 and joda-time

Posted by Musachy Barroso <mu...@gmail.com>.
It doesn't mean that it will convert from string to a joda object, it
means that it will convert a string in ISO 8601 format, to a Date
object. The patch in that ticket used joda lib to create the ISO 8601,
if I don't remember wrong.

musachy

On Tue, Dec 16, 2008 at 5:09 PM, Andreas Joseph Krogh
<an...@officenet.no> wrote:
> Hi all.
> I'm trying trunk now with a field in my domain-object (User) with a property of type DateTime:
>
> private DateTime birthDate;
>
> Then I have a datepicker in my JSP operation on this property:
> <sx:datetimepicker name="user.birthDate" displayFormat="yyyy.MM.dd"/>
> And it renders the date correctly
>
> The problem is that it's failing when trying to save the form:
>
> 2008-12-16 23:01:14,874 DEBUG [UserAction.java:100] : In prepare()
> ognl.MethodFailedException: Method "setBirthDate" failed for object no.officenet.mvctest.struts2.backend.model.User@cca81013 [java.lang.NoSuchMethodException: setBirthDate([Ljava.lang.String;)]
>
> Is this supposed to work? I thought so, reading this:
> The comment in WW-2476 saying that "This was resolved as part of XW-473", what does it actually mean?
>
> --
> Andreas Joseph Krogh <an...@officenet.no>
> Senior Software Developer / CEO
> ------------------------+---------------------------------------------+
> OfficeNet AS            | The most difficult thing in the world is to |
> Karenslyst Allé 11      | know how to do a thing and to watch         |
> PO. Box 529 Skøyen      | somebody else doing it wrong, without       |
> 0214 Oslo               | comment.                                    |
> NORWAY                  |                                             |
> Tlf:    +47 24 15 38 90 |                                             |
> Fax:    +47 24 15 38 91 |                                             |
> Mobile: +47 909  56 963 |                                             |
> ------------------------+---------------------------------------------+
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>



-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org