I'm having some trouble while trying to use the Freemarker Template to display dates in the desired format.

I store points with a date information in a PostGIS database written through an FME-process in an ISO format (%Y-%m-%d) to use them in an time-enabled WMS with GeoServer.

When calling the GetFeatureInfo, the date is displayed in the following format 10/4/12 12:00 AM, where it should be 2012-10-04. We allready changened the server setting to -Dorg.geotools.localDateTimeHandling=true -Duser.country=DE -Duser.timezone=GMT -Duser.language=de.

Since this didn't give the desired outcome, we tried it with the Freemarker Template. The idea was to check the attributes for date format and format them accordingly. Somehow, I can't make it work. I tried this:

<#if attribute.is_unknown_date_like>

I get an error message for the line where the condition starts:


How can I make this condition statement work?

Edit 01.07.2020:

I realized that I should use attribute?is_data_like with a ? since it is a build-in. With this change, the error message gets more significant.

2020-07-01 08:19:02,521 ERROR [geoserver.ows] -  freemarker.core.ParseException: Error on line 29, column 46, in template content.ftl Found is_date_like, expecting one of:  is_directive,  parent,  js_string,  j_string,  uncap_first,  is_transform,  number,  is_hash,  trim,  children,  has_content,   iso_ms,  xml,  iso_utc,  byte,  double,  left_pad,  matches,  capitalize,  number_to_datetime,   contains,  size,  iso_local_h_nz,  iso_utc_ms,  iso_local_m_nz,  is_collection,  long,  default,  iso_utc_h_nz,  iso_local_ms,  is_boolean,  last_index_of,  c,  iso_utc_m_nz,   is_macro,  rtf,  iso_utc_nz,  upper_case,  node_name,  reverse,  cap_first,  url,  is_hash_ex,   iso_nz,  is_enumerable,  exists,  number_to_date,  first,  iso_local,  date,  iso,  replace,  float,   right_pad,  datetime,  node_type,  split,  iso_ms_nz,  number_to_time,  is_sequence,  iso_utc_m,  html,   ancestors,  iso_utc_h,  iso_local_ms_nz,  new,  last,  sort,  eval,  lower_case,  web_safe,  is_date,   is_string,  iso_local_nz,  word_list,  seq_last_index_of,  node_namespace,  string,  keys,  iso_m_nz,  values,   seq_index_of,  chunk,  sort_by,  iso_m,  starts_with,  substring,  index_of,  iso_h,  root,  floor,  iso_h_nz,   ceiling,  if_exists,  chop_linebreak,  iso_local_h,  length,  is_indexable,  groups,  is_node,  iso_local_m,  int,   iso_utc_ms_nz,  xhtml,  ends_with,  round,  interpret,  is_method,  namespace,  short,  seq_contains,  time,   is_number  in content.ftl

So, the problem seems to lie within the built-in. As statet in the error message, Freemarker expects is_date instead of is_date_like, eventhough in the Freemarker documentation it is stated that is_date_like should be uses instead of is_date https://freemarker.apache.org/docs/ref_builtins_expert.html.

So I tried the following:

<#if attribute.value?is_date>

Now, no error message appears, but the date format is unchanged.

  • Welcome to Geographic Information Systems! Please use the edit button to update your question with the whole exception message – Ian Turton Jun 30 '20 at 12:59

From the free marker documentation it looks as if atribute.value?date should do it but I lack a suitable datey dataset to test on right now.

  • 1
    Thank you for your Help. Unfortunately it doesn't solve the problem. I still get an error message. I think the problem lies within the condition and the condition statement. I fear I haven't been precisely enough in my Question. I will edit it. – ErikBoehm Jun 30 '20 at 12:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.