Question

Why are empty values replaced with today's date in the DateFormatter

  • 14 September 2016
  • 3 replies
  • 1 view

Userlevel 3
Badge +13

Some of my features are sent to the DateFormatter with empty values in the formatted attribute, but they come out with today's date. Why does this happen, and how do I stop this?


3 replies

Userlevel 2
Badge +17

The DateFormatter (edit: not DateSetter) is set to use Automatic detection of the date format. When set this way, the transformer tries many different methods to produce a valid date. However one of these methods interprets a blank as the current date. To avoid this, please use specify a date format, or test for blank values before formatting.

Userlevel 4

The DateFormatter (edit: not DateSetter) is set to use Automatic detection of the date format. When set this way, the transformer tries many different methods to produce a valid date. However one of these methods interprets a blank as the current date. To avoid this, please use specify a date format, or test for blank values before formatting.

I'm guessing you meant the DateFormatter and not the DateSetter? :-)
Userlevel 2
Badge +17

I was not able to reproduce the issue, with FME 2016.1.3.1. e.g.

0684Q00000ArJnKQAV.png

Result: the empty attribute has not been touched, "today" has been replaced with today's date.

Attribute(encoded: utf-8): `_date_empty' has value `'
Attribute(encoded: utf-8): `_date_today' has value `20170114'
However, it seems that the DateFormatter always considers the empty string as a valid date format string. That is, the transformer does nothing for empty attributes even if you set a non-empty value or the null to the "Set Invalid Date Attributes To" parameter. I don't know if it's an intentional behavior.

Reply