An example would be:
package org.joda.time;
public class PeriodPropertyEditor extends PropertyEditorSupport {
public void setAsText(String text) throws IllegalArgumentException {
Period period = new Period(text);
setValue(period);
}
}
Pretty basic. DateTime is equally easy, although Duration poses a
slight problem, since it can only accept Strings of the form PTxMyS,
with no support for hours or days. But that's no big deal. You may
want to use more sophisticated string-to-type conversions in some cases.
In terms of Spring usage, you would be able to have a bean with a
property of a Joda-Time type, which spring would coerce via the custom
editor
public class MyBean
void setPeriod(Period p) {
...
}
}
<beans>
<bean
class="org.springframework.beans.factory.config.CustomEditorConfigurer">
<property name="customEditors">
<map>
<entry key="org.joda.time.Period">
<bean class="org.joda.time.PeriodPropertyEditor"/>
</entry>
</map>
</property>
</bean>
<bean class="MyBean">
<property name="period" value="PT60S"/>
</bean>
</beans>
This could be a candidate fore the joda-time contrib section, but given
that it has no non-JRE dependencies, it could be rolled into the main
joda-time distro. The property editor framework also applies to
AWT/Spring frameworks.
kenny
> ------------------------------
>
> Message: 2
> Date: Mon, 13 Nov 2006 12:23:59 +0000
> From: "Stephen Colebourne" <[EMAIL PROTECTED]>
> Subject: Re: [Joda-interest] Adding PropertyEditors to joda-time
> To: "Discussion of the Joda project"
> <[email protected]>
> Message-ID:
> <[EMAIL PROTECTED]>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> Could you send us your code, even in its crude form, so we can see
> what you mean. And an example of how it gets used (eg. a link to a
> spring page, or a code sample) would be great too.
>
> Stephen
>
>
> On 13/11/06, Kenny MacLeod <[EMAIL PROTECTED]> wrote:
>> Hi all,
>>
>> Could some java.beans.PropertyEditor types be added to the joda-time
>> API? These are fairly easy to implement, and allow conversion of
>> Strings to target types using the standard beans framework.
>>
>> My personal interest in this is to allow easier use of joda-time within
>> spring-managed beans (spring just uses standard java.beans stuff to
>> coerce property types). I've written some crude property editors that
>> can target Duration and Period types, but a more comprehensive set of
>> PropertyEditors built-in to joda-time would be preferable.
>>
>> kenny
>>
>>
>> -------------------------------------------------------------------------
>> Using Tomcat but need to do more? Need to support web services, security?
>> Get stuff done quickly with pre-integrated technology to make your job easier
>> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
>> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
>> _______________________________________________
>> Joda-interest mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/joda-interest
>>
>
>
>
> ------------------------------
>
> -------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
>
> ------------------------------
>
> _______________________________________________
> Joda-interest mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/joda-interest
>
>
> End of Joda-interest Digest, Vol 6, Issue 9
> *******************************************
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Joda-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/joda-interest