From: yako_69@hotmail.fr
To: jody.garnett@gmail.com
Subject: RE: [Geotools-gt2-users] (no subject)
Date: Thu, 23 Apr 2009 11:25:52 +0200



> Date: Tue, 21 Apr 2009 12:00:42 +1000
> Subject: Re: [Geotools-gt2-users] (no subject)
> From: jody.garnett@gmail.com
> To: yako_69@hotmail.fr
> CC: geotools-gt2-users@lists.sourceforge.net
>
> Date handling is always a mess; please look at the XML specifications
> for what ever iso format is used to communicates dates between systems
> (I cannot remember). Or check the geotools codebase where there is
> some date formatting/handling functions that can be used.
>
> Can you try just using your Date objects directly?
>
> Jody


Hi Jody,

I tried those 3 ways :

String startDateString = "28/04/2009";
String endDateString = "29/04/2009";
DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
java.util.Date startDate = null;
java.util.Date endDate = null;

try
{
 startDate = (Date)formatter.parse(startDateString);
 endDate = (Date)formatter.parse(endDateString);
}
catch (ParseException e)
{
 e.printStackTrace();
}

FeatureStore<SimpleFeatureType,SimpleFeature> fs = getFeatureStore("roads");
GeometryFactory geomFactory = new GeometryFactory();
Point point = geomFactory.createPoint( new Coordinate(0, 0));
FeatureCollection<SimpleFeatureType, SimpleFeature> collection = FeatureCollections.newCollection("internal");

(1) ----- final SimpleFeature feature = SimpleFeatureBuilder.build( fs.getSchema(), new Object[] {new java.sql.Timestamp(startDate.getTime()), new java.sql.Timestamp(endDate.getTime()), "bla bla", point}, null );

(2) -----final SimpleFeature feature = SimpleFeatureBuilder.build( fs.getSchema(), new Object[] {startDate, endDate, "bla bla", point}, null );

(3) -----final SimpleFeature feature = SimpleFeatureBuilder.build( fs.getSchema(), new Object[] {"2009-04-28T00:00:00", "2009-04-29T00:00:00", "bla bla", point}, null );

collection.add(feature);
fs.addFeatures(collection);

And I get thoses Errors:
(1) 23 avr. 2009 11:15:14 org.geotools.xml.XMLSAXHandler processException
GRAVE: java.lang.RuntimeException: Parsing failed for date_debut: java.lang.IllegalArgumentException: Failed to parse dateTime 2009-04-28 00:00:00.0 at: 00:00:00.0
Parsing failed for date_debut: java.lang.IllegalArgumentException: Failed to parse dateTime 2009-04-28 00:00:00.0 at: 00:00:00.0
Failed to parse dateTime 2009-04-28 00:00:00.0 at: 00:00:00.0    org.geotools.xml.filter.FilterComplexTypes$ServiceExceptionType.getValue(FilterComplexTypes.java:1669)
    org.geotools.xml.handlers.ComplexElementHandler.endElement(ComplexElementHandler.java:157)
    org.geotools.xml.XMLSAXHandler.endElement(XMLSAXHandler.java:266)


(2) 23 avr. 2009 11:14:12 org.geotools.xml.XMLSAXHandler processException
GRAVE: java.lang.RuntimeException: Parsing failed for date_debut: java.lang.IllegalArgumentException: Failed to parse dateTime Tue Apr 28 00:00:00 CEST 2009 at:Tue Apr 28 00:00:00 CEST 2009
Parsing failed for date_debut: java.lang.IllegalArgumentException: Failed to parse dateTime Tue Apr 28 00:00:00 CEST 2009 at:Tue Apr 28 00:00:00 CEST 2009
Failed to parse dateTime Tue Apr 28 00:00:00 CEST 2009 at:Tue Apr 28 00:00:00 CEST 2009    org.geotools.xml.filter.FilterComplexTypes$ServiceExceptionType.getValue(FilterComplexTypes.java:1669)
    org.geotools.xml.handlers.ComplexElementHandler.endElement(ComplexElementHandler.java:157)
    org.geotools.xml.XMLSAXHandler.endElement(XMLSAXHandler.java:266)


(3) 23 avr. 2009 11:12:28 org.geotools.xml.XMLSAXHandler processException
GRAVE: java.lang.RuntimeException: Parsing failed for date_debut: java.lang.IllegalArgumentException: Failed to parse dateTime Tue Apr 28 02:00:00 CEST 2009 at:Tue Apr 28 02:00:00 CEST 2009
Parsing failed for date_debut: java.lang.IllegalArgumentException: Failed to parse dateTime Tue Apr 28 02:00:00 CEST 2009 at:Tue Apr 28 02:00:00 CEST 2009
Failed to parse dateTime Tue Apr 28 02:00:00 CEST 2009 at:Tue Apr 28 02:00:00 CEST 2009    org.geotools.xml.filter.FilterComplexTypes$ServiceExceptionType.getValue(FilterComplexTypes.java:1669)
    org.geotools.xml.handlers.ComplexElementHandler.endElement(ComplexElementHandler.java:157)
    org.geotools.xml.XMLSAXHandler.endElement(XMLSAXHandler.java:266)

   
For the first case, It works with a PostGIS data store but not with WFS-T data store (GeoServer)
I think the format defined here : http://www.w3.org/TR/xmlschema-2/#dateTime is not respected
It looks like a 'T' is missing between the date and the time. It should be 2009-04-28T00:00:00.0.

Is this a bug? I'm Using Geotools 2.5.4.
Can I find a working example somewhere ?

Thank You,

Yako Bak.




Vous voulez savoir ce que vous pouvez faire avec le nouveau Windows Live ? Lancez-vous !

Votre correspondant a choisi Hotmail et profite d'un stockage quasiment illimité. Créez un compte Hotmail gratuitement !