title: Input type="date" thymeleaf
body: <p>I need to add date to my entity and let the user set it in web form.
  This field needs to have today's date filled in by default.</p>
  
  <pre><code>1. &lt;input type="date" value="2016-08-01"&gt; 
  </code></pre>
  
  <p>shows correct date setted for default </p>
  
  <pre><code>2. &lt;input type="date" th:value="${startDate}"&gt; 
  </code></pre>
  
  <p>shows date picker without any value (note: String startDate = "2016-08-01";) </p>
  
  <pre><code>3. &lt;input type="date" th:field="${startDate}"&gt; 
  </code></pre>
  
  <p>generates 400 error (Bad request) (note: Date startDate = new Date();) </p>
  
  <p>So, question is: how to use thymeleaf for input date?</p>
  
  <ul>
  <li>can I use Date() datatype for input and store such data?</li>
  <li>how I need to set "th:field" in  form?</li>
  <li>how I need to set "th:value" in same form?</li>
  </ul>
  
  <p>My controller(s):</p>
  
  <pre><code>@RequestMapping("/project_new")
  public String createProject(Model model) {
      Project project = new Project ();
      List&lt;Role&gt; roles = mRoleService.findAll();
  
      project.setStart(new Date());
  
      model.addAttribute("page_title", "create project");
      model.addAttribute("roles", roles);
      model.addAttribute("statuses", Status.values());
      model.addAttribute("project", project);
      return "project_new";
  }
  
  @RequestMapping(value = "/project_new", method = RequestMethod.POST)
  public String createProject(@ModelAttribute Project project, Model model) {
      // Fill id field for project.rolesNeeded
      mRoleService.setRolesId(project.getRolesNeeded());
      project.fixCollaboratorsAndRoles();
  
      mProjectService.save(project);
      return "redirect:/";
  }
  </code></pre>
  
  <p>My template:</p>
  
  <pre><code>&lt;form th:action="@{/project_new}" method="post" th:object="${project}"&gt;
    &lt;div class="project-list single"&gt;
      &lt;label for="name"&gt;Name:&lt;/label&gt;
      &lt;input type="text" id="name" required="true" th:placeholder="*{name}" th:value="*{name}" th:field="*{name}"/&gt;
      &lt;label for="description"&gt;Description:&lt;/label&gt;
      &lt;textarea rows="5" id="description" type="text"  required="true" th:placeholder="*{description}" th:value="*{description}" th:field="*{description}"/&gt;
  
      &lt;label for="date-started"&gt;Date started:&lt;/label&gt;
      &lt;input type="date" th:value="${project.start}" th:field="${project.start}" id="date-started"/&gt;
  
      &lt;div&gt;
        &lt;label for="project_status"&gt;Project Status:&lt;/label&gt;
        &lt;div class="custom-select"&gt;
          &lt;span class="dropdown-arrow"&gt;&lt;/span&gt;
          &lt;select th:field="*{status}" id="project_status"&gt;
            &lt;option th:each="s : ${statuses}" th:value="${s}" th:text="${s}"&gt;Active&lt;/option&gt;
          &lt;/select&gt;
        &lt;/div&gt;
      &lt;/div&gt;
  
    &lt;div class="roles-collaborators"&gt;
      &lt;ul class="checkbox-list"&gt;
        &lt;li th:if="${role.name} ne 'Undefined'" th:each="role : ${roles}"&gt;
        &lt;input type="checkbox"  th:value="${role}" th:field="${project.rolesNeeded}" class="checkbox"/&gt;
        &lt;span th:text="${role.name}" th:value="${role}" class="checkbox"&gt;Developer&lt;/span&gt;
        &lt;/li&gt;
      &lt;/ul&gt;
    &lt;/div&gt;
  
    &lt;div class="actions"&gt;
      &lt;button type="submit" class="button"&gt;Save&lt;/button&gt;
      &lt;a th:href="@{/}" class="button button-secondary"&gt;Cancel&lt;/a&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Project entity:</p>
  
  <pre><code>@Entity
  public class Project {
  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  private Long id;
  
  @NotNull
  @Size (min = 3)
  private String name;
  
  @Column(columnDefinition="TEXT")
  private String description;
  
  @Column
  private Status status;
  
  @Column
  private Date start;
  
  @ManyToMany
  @LazyCollection(LazyCollectionOption.FALSE)
  private List&lt;Role&gt; rolesNeeded;
  
  @ManyToMany
  @LazyCollection(LazyCollectionOption.FALSE)
  private List&lt;Collaborator&gt; collaborators;
  
  public Date getStart() {
      return start;
  }
  
  public void setStart(Date start) {
      this.start = start;
  }
  </code></pre>