title: Freemarker date format - different on different machines?
body: <p>I have a problem where my Freemarker template produces different date formats on different machines.</p>
  
  <p>My Freemarker macro looks like this:</p>
  
  <pre><code>&lt;#macro renderTextEntry textEntry&gt;
      &lt;div id="text_entry_${textEntry.id}" class="text_entry"&gt;
          &lt;span id="text_entry_${textEntry.id}_date" class="text_entry_date"&gt;${textEntry.time?datetime}&lt;/span&gt;:
          &lt;div id="text_entry_${textEntry.id}_content" class="text_entry_content"&gt;&lt;#noescape&gt;${textEntry.text}&lt;/#noescape&gt;&lt;/div&gt;
          &lt;button class="edit_text_entry"&gt;Edit&lt;/button&gt;
          &lt;a class="delete_text_entry" href="/delete-text-entry?id=${textEntry.id}"&gt;&lt;img
                  src="images/delete.png" alt="delete text entry"/&gt;&lt;/a&gt;
      &lt;/div&gt;
  &lt;/#macro&gt;
  </code></pre>
  
  <p>I have a unit test for the outcome, with the expected outcome being this:</p>
  
  <pre><code>&lt;div id="text_entry_5" class="text_entry"&gt;
      &lt;span id="text_entry_5_date" class="text_entry_date"&gt;Jan 2, 1970 11:17:36 AM&lt;/span&gt;:
      &lt;div id="text_entry_5_content" class="text_entry_content"&gt;some text&lt;/div&gt;
          &lt;button class="edit_text_entry"&gt;Edit&lt;/button&gt;
          &lt;a class="delete_text_entry" href="/delete-text-entry?id=5"&gt;
              &lt;img src="images/delete.png" alt="delete text entry"/&gt;
          &lt;/a&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>One one machine this test passes. On another, it fails. The only difference is that the date is output as</p>
  
  <pre><code>02-Jan-1970 11:17:36
  </code></pre>
  
  <p>TextEntry.getDate() returns a java.util.Date object.</p>
  
  <p>Both machines are MacbookPros running OSX 10.7.5 and Java 1.7.0_10-b18. I am not aware of any environment variables I have set that affects the default DateFormat - simply running</p>
  
  <pre><code>System.out.println(new Date());
  </code></pre>
  
  <p>produces the same output on both machines. I have no idea what is going on here - any help would be greatly appreciated!</p>
  
  <p>NOTE: I have solved my problem by explicitly declaring the date format I want - the relevant Freemarker snippet is now</p>
  
  <pre><code>${textEntry.time?string("MMM d, yyyy HH:mm:ss a")}
  </code></pre>
  
  <p>However, it would still be nice to understand what is going on here!</p>