WMS GetFeatureInfo formats text/html, text/plain, text/xml and application/vnd.ogc.gml (GML2) don't handle time correctly

Description

The following formats: GeoJson, GML 3.1 and GML 3.2 have the correct default behavior, i.e. they take into account the timezone when encoding a date \ time attribute.

The following formats: text/html, text/plain, text/xml and application/vnd.ogc.gml (GML2), don't have any special treatment for date \ times and simply do a to string regardless of the timezone or time format.

For example the text/plain output format time encoding:
https://github.com/nmco/geoserver/blob/8d5c1dbc774e68baf445354bcb5e5fc2d5c122e3/src/wms/src/main/java/org/geoserver/wms/featureinfo/TextFeatureInfoOutputFormat.java#L106-L135

It should also be possible to control if GeoServer will or will not take into account the the time zone when encoding date \ time attributes using this Java property:

-Dorg.geotools.localDateTimeHandling=true

Formats GeoJson, GML 3.1 and GML 3.2 have the correct default behavior are taking into account this flag.

To reproduce this issue just perform a WMS GetFeatureInfo in a layer with a time attribute. Formats GeoJson, GML 3.1 and GML 3.2 will encode the time values with the proper time zone information but the other formats will just to a simple to srng.

Environment

None

Status

Assignee

Fernando Miño

Reporter

Nuno Oliveira

Triage

Fix versions

Affects versions

2.12.0

Components

Priority

High
Configure