How to Assign Null or "Empty" Values to Freemarker Time Variables?
<p>I'm using Freemarker to build a Liferay Application Display Template. The Template uses a loop to iterate over a Set of Entities (Journal Articles). The Template uses several Variables of Type Date and Time. How may I reset these Variables or check for "empty" in each Iteration of the Loop?</p>

<p>Let's say we have this Code inside the Loop, and it's possible that "starthour" may be empty in some Interations of the Loop:</p>

<pre><code>&lt;#assign xPathSelector = saxReaderUtil.createXPath("dynamic-element[@name='start_hour']") /&gt;
&lt;#assign starthour = xPathSelector.selectSingleNode(rootElement).getStringValue()?trim /&gt;
&lt;#assign xPathSelector = saxReaderUtil.createXPath("dynamic-element[@name='start_minutes']") /&gt;
&lt;#assign startminutes = xPathSelector.selectSingleNode(rootElement).getStringValue()?trim /&gt;
&lt;#if starthour!=""&gt;
  &lt;#assign startTimeString=  starthour +":"+startminutes&gt;
  &lt;#assign starttime = startTimeString?time["HH:mm"]&gt;
&lt;#else&gt;
 &lt;#assign starttime = 0&gt;
&lt;/#if&gt;
</code></pre>

<p>In this Example I've set starttime to 0, but I've also tried to set it as empty String when starthour is empty. </p>

<p>I already tried these Methods to check for the "empty" Variable:</p>

<pre><code>&lt;#if (starttime &gt;0) &gt;
&lt;#if starttime.has_content&gt;
&lt;#if starttime!=""&gt;
</code></pre>

<p>I can't check</p>

<pre><code>&lt;#if starttime??&gt;
</code></pre>

<p>after the Variable has once been set in my Loop. Whatever I try I always get Errors like this one, when I use my Script in Liferay:</p>

<pre><code>The only legal comparisons are between two numbers, two strings, or two dates.
Left  hand operand is a freemarker.template.SimpleDate
Right hand operand is a freemarker.template.SimpleNumber
</code></pre>

<p>So how do I "reset" a Time Variable or set an "empty" Value for it, and how to check for an empty (but not Null) Time Value?</p>