Hi, Yes, the toString() method of java.sql.Date class format the date in JDBC date escape format (yyyy-mm-dd).
I'll see on the Cocoon side if I could define a date format. Thanks again Regards Sylvain > -----Message d'origine----- > De: Charles Anthony [mailto:[EMAIL PROTECTED] > Date: mardi, 18. novembre 2003 11:11 > �: 'OJB Users List' > Objet: RE: Problem with dates conversion > > > Hi, > > OK - you are correct, dates are stored as a number of > milliseconds since a > certain time. > > java.util.Date and java.sql.Date have toString methods that > convert that > number of milliseconds into a date string. However, those > toString methods > have hard-coded patterns, which are the formats you are seeing. > > It is not possible to change those formats. > > What you need to do is to get Cocoon to specify a date format > to display the > dates in. I believe we have some Cocoon users on the list - > could someone > please tell Sylvain how to specify a dateformat ? > > I'm not a cocoon user, but a quick google provides : > http://cocoon.apache.org/2.1/userdocs/flow/jxtemplate.html#formatDate > > Cheers, > > Charles. > > > -----Original Message----- > > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] > > Sent: 18 November 2003 09:47 > > To: [EMAIL PROTECTED] > > Subject: RE: Problem with dates conversion > > > > > > Hi, > > > > In fact I'm talking about a java web application using Apache > > Cocoon framework. > > > > When I instantiate and retrieve from database an Application > > object, I notice that this releaseDate is stored in a "number > > of seconds" format. > > When I display this date, I simply take the value using a > > XPath expression (application.releaseDate) and put it into > > the web page. > > So I thought that I could define the "conversion" format > > somewhere because this date seems to be converted form a > > "number of seconds" format to an other format. > > > > Regards > > Sylvain > > > > > -----Message d'origine----- > > > De: Charles Anthony [mailto:[EMAIL PROTECTED] > > > Date: mardi, 18. novembre 2003 10:26 > > > �: 'OJB Users List' > > > Objet: RE: Problem with dates conversion > > > > > > > > > Hi, > > > > > > Displayed where, in what, and how ? > > > > > > Are we talking java web application, swing application, > > > console application > > > ? > > > > > > Essentially : if you want to display a date in a given > > > format, you have to > > > use a DateFormat. There is no other way - it is really, > > > really simple as I > > > showed you before; it only takes 2 lines of code - and that > > > could be reduced > > > to one if you created a helper function/class. > > > > > > Cheers, > > > > > > Charles. > > > > > > > > > > -----Original Message----- > > > > From: [EMAIL PROTECTED] > > > [mailto:[EMAIL PROTECTED] > > > > Sent: 18 November 2003 09:28 > > > > To: [EMAIL PROTECTED] > > > > Subject: RE: Problem with dates conversion > > > > > > > > > > > > Hi again, > > > > > > > > My problem is to display dates in European format. > > > > > > > > If I use java.sql.Date in the Application class the date is > > > > displayed as: 2003-11-26 > > > > If I use java.util.Date the date is displayed as: Wed Nov 26 > > > > 00:00:00 CET 2003 > > > > > > > > I would like to have the format: dd.mm.yyyy. > > > > I thought that we could define the format in OJB. > > > > > > > > I could do the conversion with Java but it's lot of work. > > > > > > > > What do you think? > > > > Thanks > > > > Regards > > > > Sylvain > > > > > > > > > -----Message d'origine----- > > > > > De: Charles Anthony [mailto:[EMAIL PROTECTED] > > > > > Date: mardi, 18. novembre 2003 10:09 > > > > > �: 'OJB Users List' > > > > > Objet: RE: Problem with dates conversion > > > > > > > > > > > > > > > Sylain, what precisely is the problem you have ? > > > > > > > > > > Cheers, > > > > > > > > > > Charles. > > > > > > > > > > > -----Original Message----- > > > > > > From: [EMAIL PROTECTED] > > > > > [mailto:[EMAIL PROTECTED] > > > > > > Sent: 18 November 2003 09:11 > > > > > > To: [EMAIL PROTECTED] > > > > > > Subject: RE: Problem with dates conversion > > > > > > > > > > > > > > > > > > Hi, > > > > > > > > > > > > Yes you're right! > > > > > > > > > > > > But the conversion doesn't change anything for me. > > > > > > > > > > > > Regards > > > > > > Sylvain > > > > > > > > > > > > > -----Message d'origine----- > > > > > > > De: Charles Anthony > [mailto:[EMAIL PROTECTED] > > > > > > > Date: mardi, 18. novembre 2003 09:47 > > > > > > > �: 'OJB Users List' > > > > > > > Objet: RE: Problem with dates conversion > > > > > > > > > > > > > > > > > > > > > Hi, > > > > > > > > > > > > > > Check your class. I think you'll find that > > > > > > > Application.releaseDate is a > > > > > > > java.sql.Date and *not* a java.util.Date. > > > > > > > > > > > > > > The error message is saying > > > > > > > "com.itservices.woc.data.Application has an > > > > > > > attribute releaseDate with a type of java.sql.Date, but I > > > > > > > have a value of > > > > > > > java.util.Date". > > > > > > > > > > > > > > JavaDate2SqlDateFieldConversion converts betwen > jdbc dates > > > > > > > (java.sql.Date) > > > > > > > into java dates (java.util.Date) when reading from the > > > > > > datase, and the > > > > > > > reverse when writing to the database. > > > > > > > > > > > > > > Either > > > > > > > a) Don't use the conversion or > > > > > > > b) change the attribute to be java.util.Date > > > > > > > > > > > > > > Cheers, > > > > > > > > > > > > > > Charles. > > > > > > > > > > > > > > > -----Original Message----- > > > > > > > > From: [EMAIL PROTECTED] > > > > > > > [mailto:[EMAIL PROTECTED] > > > > > > > > Sent: 18 November 2003 08:43 > > > > > > > > To: [EMAIL PROTECTED] > > > > > > > > Subject: Problem with dates conversion > > > > > > > > > > > > > > > > > > > > > > > > Hello, > > > > > > > > > > > > > > > > Trying to use the field conversion: > > > > > > > > > > > > > > > > I have a class "Application" that has an attribute > > > > > > > > "releaseDate" to store a date (no time). > > > > > > > > In my database (MS SQL) the type is: datetime. > > > > > > > > In OJB repository the jdbc-type is: DATE. > > > > > > > > In my java code I use the class java.util.Date. > > > > > > > > > > > > > > > > I added the line below in OJB repository: > > > > > > > > > > > conversion="org.apache.ojb.broker.accesslayer.conversions.Java > > > > > > > > Date2SqlDateFieldConversion" > > > > > > > > > > > > > > > > But this produces an error: > > > > > > > > > > > > > > > > [DEFAULT] ERROR: Error in operation [set] of object > > > > > > > > [PersistentFieldPropertyImpl], > > > > > java.lang.IllegalArgumentException > > > > > > > > [DEFAULT] ERROR: Declaring class > > > > > > > [com.itservices.woc.data.Application] > > > > > > > > [DEFAULT] ERROR: Property Name [releaseDate] > > > > > > > > [DEFAULT] ERROR: Property Type [java.sql.Date] > > > > > > > > [DEFAULT] ERROR: anObject was class > > > > > > > > [com.itservices.woc.data.Application] > > > > > > > > [DEFAULT] ERROR: aValue was class [java.util.Date] > > > > > > > > org.apache.ojb.broker.PersistenceBrokerException: > > Unable to > > > > > > > > build object instance :class > > > > com.itservices.woc.data.Application > > > > > > > > at > > > > > > > > > > > org.apache.ojb.broker.accesslayer.RowReaderDefaultImpl.buildWi > > > > > > > > thReflection(Unknown Source) > > > > > > > > at > > > > > > > > > > > org.apache.ojb.broker.accesslayer.RowReaderDefaultImpl.readObj > > > > > > > > ectFrom(Unknown Source) > > > > > > > > at > > > > > > > > > > > org.apache.ojb.broker.accesslayer.RsIterator.getObjectFromResu > > > > > > > > ltSet(Unknown Source) > > > > > > > > at > > > > > > > > > > > > > > > org.apache.ojb.broker.accesslayer.RsIterator.next(Unknown Source) > > > > > > > > etc... > > > > > > > > > > > > > > > > Could you help me? > > > > > > > > Thanks > > > > > > > > Sylvain > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > > > > > To unsubscribe, e-mail: > [EMAIL PROTECTED] > > > > > > > > For additional commands, e-mail: > > [EMAIL PROTECTED] > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ___________________________________________________________ > > > > > > > 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] > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > > > > > > > > > > > > > > > > > > ___________________________________________________________ > > > > > 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] > > > > > > > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > > > > > > > > ___________________________________________________________ > > > 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] > > > > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > ___________________________________________________________ > 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] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
