> Imagine, you use the DummyCalendar in Calendar2DateFieldConversion.
> 
> javaToSql will be ok.
>   (... if (source instanceof Calendar) ...)
> 
> but sqlToJava will materialize not the DummyCalendar (that you need), 
> but a GregorianCalendar.
>   (... GregorianCalendar cal = new GregorianCalendar()...)
> 
>   public class TestThingy2 extends TestCase
>   {
>     public void testCalendarConv()
>     {
>       DummyCalendar dc0 = new DummyCalendar();
>       Date d = Calendar2DateFieldConversion.javaToSql(dc);
>       Calendar dc1 = Calendar2DateFieldConversion.javaToSql(d);
> 
>       assertEquals(dc1, dc0); //will fail
> 
>       DummyCalendar dc2 = (DummyCalendar)dc1; //will fail
>     }
>   }
> 

Absolutely - but then you must create your own conversion strategy !
Instanceof has nothing to do with this.

The Fieldconversion implementation must know what calendar implementation to
instantiate (although Calendar2DateFieldConversion should, probably, do
Calendar.getInstance and not instantiate GregorianCalendar directly) - and
it can't derive this information for the java.sql.Date

If you want to convert java.sql.Date <--> DummyCalendar then you have to
create a DummyCalendar2DateFileConversion class...

Cheers,

Charles.


___________________________________________________________
HPD Software Ltd. - Helping Business Finance Business
Email terms and conditions: www.hpdsoftware.com/disclaimer 



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to