title: Formatting th:field in Thymeleaf
body: <p>I have a form input field in Thymeleaf. The field (bookingEntry.datefrom in the code snippet below) is type Date. I use a datepicker to allow the user to select and format the required date to enter the field. This is all fine.</p>
  
  <p>However, I want the initial value of the date (which I have set to the current date) to be displayed in the format that I choose. So, how do I format the date initially shown in a th:field. th:value is ignored (Thymeleaf is getting the value from the backing object, as it should) and I can't seem to apply a format to the th:field.</p>
  
  <p>Thymeleaf code is:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;input type="text" class="form-control getdate"
         th:field="*{datefrom}" placeholder="Date From"
         th:value="${#dates.format(bookingEntry.datefrom, 'dd-MMM-yyyy')}"/&gt;
  </code></pre>
  
  <p>I'm sure that I could use a String which is initialise in any format that I choose, rather than a Date type, but I wondered if there was a way to format initial values in a th:field?</p>
  
  <p>Many thanks</p>