This one time, at band camp, Bruce Snyder said:
BS>This one time, at band camp, DU SONG Romuald said:
BS>
BS>DSR>You're not holding the cloned SimpleDateFormat, but you are rebuilding
BS>DSR>a clone of the clone. Is it necessary to keep last format used ?
BS>DSR>
BS>DSR>It might be safer and quicker to do something like this :
BS>DSR> public Object convert( Object obj, String param ) {
BS>DSR> try {
BS>DSR> SimpleDateFormat fmt =
BS>DSR>getParamDateFormat().applyPattern(
BS>DSR> org.exolab.castor.mapping.loader.Types.getFullDatePattern( param ) );
BS>DSR>
BS>DSR> return fmt.parse( obj.toString() );
BS>DSR> } catch ( ParseException except ) {
BS>DSR> throw new IllegalArgumentException( except.toString()
BS>DSR>);
BS>DSR> }
BS>DSR> }
BS>DSR> } ),
BS>DSR>
BS>DSR>This way, we are cloning, but we don't need to synchronize.
BS>
BS>This is a much more polished solution to this problem. Holding a local
BS>clone of the getter/setter clone is a better solution. I like the fact
BS>that we're avoiding synchronization and that we're avoiding asking for the
BS>clone from the getters/setters.
BS>
BS>This is *EXACTLY* why I love Open Source! I've just proven my point that
BS>code is improved through Open Source just from the simple fact that it's
BS>scrutinized by more people.
BS>
BS>I'll change the class and get it checked in, but I may not be able to
BS>do it until sometime over the weekend.
This change has been checked into CVS. The solution is slightly different
because applyPattern() is a void method. So there is a sample of the
solution:
public Object convert( Object obj, String param ) {
SimpleDateFormat paramDateFormat = getParamDateFormat();
paramDateFormat.applyPattern(
org.exolab.castor.mapping.loader.Types.getFullDatePattern( param ) );
return new Integer( paramDateFormat.format( (java.util.Date) obj ) );
}
Bruce
--
perl -e 'print unpack("u30","<0G)[EMAIL PROTECTED]&5R\"F9E<G)E=\$\!F<FEI+F-O;0\`\`");'
The Castor Project
http://www.castor.org/
Apache Geronimo
http://incubator.apache.org/projects/geronimo.html
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev