Hi,
I am trying send data to a date field within community mapbuilder to Geoserver which updates PostGIS/Postgres. The field is defined as date within PostGres, but when I bring it within Geoserver as a featureType I noticed that the same field is now defined as dateTime. From Community Mapbuilder I try to update the date field and I get the following error: Service Exception: java.lang.IllegalArgumentException: unable to parse 2006-11-30 as Date
I have also tried 2006-11-30:00:00:00 and Sat, 12 Aug 1995 13:30:01 which works fine when updating PostGres directly and I get similar error when going through Geoserver.
What format will work when the geoserver format is dateTime and the PostGis/PostGres is date?
Thanks,
–
John J. Mitchell
John Mitchell ha scritto:
Hi,
I am trying send data to a date field within community mapbuilder to Geoserver which updates PostGIS/Postgres. The field is defined as date within PostGres, but when I bring it within Geoserver as a featureType I noticed that the same field is now defined as dateTime. From Community Mapbuilder I try to update the date field and I get the following error: Service Exception: java.lang.IllegalArgumentException: unable to parse 2006-11-30 as Date
I have also tried 2006-11-30:00:00:00 and Sat, 12 Aug 1995 13:30:01 which works fine when updating PostGres directly and I get similar error when going through Geoserver.
What format will work when the geoserver format is dateTime and the PostGis/PostGres is date?
Geoserver uses Geotools to do the parsing and turning the object into
a Date, which in turn relies on java.text.DateFormat.getInstance(), the
default date/time parser. Which is, in turn, locale dependent (the default locale of the server you're running onto).
So... it's a guess... we should provide this info somewhere in the
geoserver configuration pages.
The following program, run on your pc, will return _your_ format:
public static void main(String args) throws ParseException, SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
SimpleDateFormat format = (SimpleDateFormat) DateFormat.getInstance();
System.out.println(format.toPattern());
System.out.println(format.parse("20/10/05 10.13"));
}
On my PC, with Italian locale, the format is: dd/MM/yy H.mm
On yours it will be different.
Cheers
Andrea
Andrea,
Thanks for the sample program! I ran it and I was able to get the correct dateTime format for the US locale of M/d/yy h:mm a
John Mitchell
On 11/29/06, Andrea Aime <aaime@anonymised.com> wrote:
John Mitchell ha scritto:
Hi,
I am trying send data to a date field within community mapbuilder to
Geoserver which updates PostGIS/Postgres. The field is defined as date
within PostGres, but when I bring it within Geoserver as a featureType
I noticed that the same field is now defined as dateTime. From
Community Mapbuilder I try to update the date field and I get the
following error: Service Exception:
java.lang.IllegalArgumentException : unable to parse 2006-11-30 as Date
I have also tried 2006-11-30:00:00:00 and Sat, 12 Aug 1995 13:30:01
which works fine when updating PostGres directly and I get similar error
when going through Geoserver.
What format will work when the geoserver format is dateTime and the
PostGis/PostGres is date?
Geoserver uses Geotools to do the parsing and turning the object into
a Date, which in turn relies on java.text.DateFormat.getInstance(), the
default date/time parser. Which is, in turn, locale dependent (the
default locale of the server you’re running onto).
So… it’s a guess… we should provide this info somewhere in the
geoserver configuration pages.
The following program, run on your pc, will return your format:
public static void main(String args) throws ParseException,
SecurityException, NoSuchFieldException, IllegalArgumentException,
IllegalAccessException {
SimpleDateFormat format = (SimpleDateFormat)
DateFormat.getInstance();
System.out.println(format.toPattern());
System.out.println(format.parse(“20/10/05 10.13”));
}
On my PC, with Italian locale, the format is: dd/MM/yy H.mm
On yours it will be different.
Cheers
Andrea
–
John J. Mitchell
John Mitchell ha scritto:
Andrea,
Thanks for the sample program! I ran it and I was able to get the correct dateTime format for the US locale of M/d/yy h:mm a
No problem... yet it takes a bit too much of work to guess this even
if you're familiar with the code, so I've opened an issue in jira:
http://jira.codehaus.org/browse/GEOS-811
Cheers
Andrea