[Geoserver-users] Change date format

Hello everyone,

I'm just wondering if it's possible to change the format that Geoserver uses
to parse the date from a database (in my case postgresql with postgis
extension).

From browsing the mailinglist I found out that it uses this method to parse

dates:
SimpleDateFormat format = (SimpleDateFormat)DateFormat.getInstance();
So is it possbile to tell Geoserver a certain format like:
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"), which is
also used in postgresql?

I'm trying to retrieve data from the backend posgresql database via
Geoserver's WFS service within a certain time period. Therefore Geoserver
has to compare my inputed timestamps with the ones in the database. When
Geoserver reads then the dates from postgresql, I get the following
execption:
java.text.ParseException: Unparseable date: "2001-02-11T20:03:00Z"
        at java.text.DateFormat.parse(DateFormat.java:337)

I need to change the format in Geoserver, because - as I understand - I
can't change the format that postgresql uses to save the dates.

Thanks in advance!

Best regards, Thalles
--
View this message in context: http://www.nabble.com/Change-date-format-tp23924131p23924131.html
Sent from the GeoServer - User mailing list archive at Nabble.com.

Thalles ha scritto:

Hello everyone,

I'm just wondering if it's possible to change the format that Geoserver uses
to parse the date from a database (in my case postgresql with postgis
extension).

From browsing the mailinglist I found out that it uses this method to parse

dates:
SimpleDateFormat format = (SimpleDateFormat)DateFormat.getInstance();
So is it possbile to tell Geoserver a certain format like:
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"), which is
also used in postgresql?

I'm trying to retrieve data from the backend posgresql database via
Geoserver's WFS service within a certain time period. Therefore Geoserver
has to compare my inputed timestamps with the ones in the database. When
Geoserver reads then the dates from postgresql, I get the following
execption:
java.text.ParseException: Unparseable date: "2001-02-11T20:03:00Z"
        at java.text.DateFormat.parse(DateFormat.java:337)

I need to change the format in Geoserver, because - as I understand - I
can't change the format that postgresql uses to save the dates.

Can you provide a full stack trace? As far as I know the code that
reads from the database does not do string parsing, it uses:
resultset.getObject(position);
which will return a java.util.Date. So the issue must be happening
somewhere else.

Cheers
Andrea

--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.

Hi,

here is the full stack trace:

java.text.ParseException: Unparseable date: "2001-02-11T20:00:14Z"
  at java.text.DateFormat.parse(DateFormat.java:337)
  at
uk.ac.york.cs.kmlservlet.constants.ConstantsAdvanced.getDateFromString(ConstantsAdvanced.java:115)
  at
uk.ac.york.cs.kmlservlet.model.TrackGeneralized.<init>(TrackGeneralized.java:52)
  at uk.ac.york.cs.kmlservlet.kml.kmlmode.KMLMode.getTracks(KMLMode.java:59)
  at
uk.ac.york.cs.kmlservlet.kml.kmlmode.TrackOverview.getKML(TrackOverview.java:43)
  at uk.ac.york.cs.kmlservlet.KMLServlet.doGet(KMLServlet.java:123)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
  at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
  at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
  at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
  at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
  at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
  at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
  at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
  at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
  at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
  at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
  at java.lang.Thread.run(Thread.java:619)

--
View this message in context: http://www.nabble.com/Change-date-format-tp23924131p23926982.html
Sent from the GeoServer - User mailing list archive at Nabble.com.

Thalles ha scritto:

Hi,

here is the full stack trace:

java.text.ParseException: Unparseable date: "2001-02-11T20:00:14Z"
  at java.text.DateFormat.parse(DateFormat.java:337)
  at
uk.ac.york.cs.kmlservlet.constants.ConstantsAdvanced.getDateFromString(ConstantsAdvanced.java:115)
  at
uk.ac.york.cs.kmlservlet.model.TrackGeneralized.<init>(TrackGeneralized.java:52)
  at uk.ac.york.cs.kmlservlet.kml.kmlmode.KMLMode.getTracks(KMLMode.java:59)
  at
uk.ac.york.cs.kmlservlet.kml.kmlmode.TrackOverview.getKML(TrackOverview.java:43)
  at uk.ac.york.cs.kmlservlet.KMLServlet.doGet(KMLServlet.java:123)

Hum... this is in your code, not in GeoServer. Maybe I did not
understand your original question? The date above is correct and
specified according to the ISO standard.

Cheers
Andrea

--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.

Yeah, also saw that it was my code producing the execption after I posted it.
I think I know how to solve it!

Thanks anyway for your help!

Bye Thalles
--
View this message in context: http://www.nabble.com/Change-date-format-tp23924131p23927286.html
Sent from the GeoServer - User mailing list archive at Nabble.com.