title: Getting Date as null when using java.sql.Date
body: <p>I am trying to insert the date into database and I am using java.sql.Date but the problem when user is submitting the form I am getting Null value. As per some restriction I am only allowed to use java.sql.Date not util.Date.</p>
  
  <p>Entity</p>
  
  <pre><code>    import java.sql.Date;
  
  import javax.persistence.Column;
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.GenerationType;
  import javax.persistence.Id;
  import javax.persistence.Table;
  import javax.validation.constraints.NotNull;
  
  import org.hibernate.validator.constraints.NotEmpty;
  import org.springframework.format.annotation.DateTimeFormat;
  
  @Entity
  @Table(name="Users")
  public class Users {
  
      @Id
      @GeneratedValue(strategy=GenerationType.IDENTITY)
      @Column(name="User_ID")
      private int ID;
  
      @Column(name="User_first_name")
      @NotEmpty(message="Field cannot be left blank")
      private String First_Name;
  
      @Column(name="user_last_name")
      private String Last_Name;
  
      @Column(name="user_contact")
      private int Contact;
  
      @Column(name="user_email")
      private String Email;
  
      @Column(name="user_date_birth")
      @DateTimeFormat(pattern="dd/MM/yyyy")
      private Date DateOfBirth;
  
      @Column(name="user_joining_date")
      private Date DateOfJoining;
  
      @Column(name="user_salary")
      @NotNull
      private int Salary;
  
      public int getID() {
          return ID;
      }
  
      public void setID(int iD) {
          ID = iD;
      }
  
      public String getFirst_Name() {
          return First_Name;
      }
  
      public void setFirst_Name(String first_Name) {
          First_Name = first_Name;
      }
  
      public String getLast_Name() {
          return Last_Name;
      }
  
      public void setLast_Name(String last_Name) {
          Last_Name = last_Name;
      }
  
      public int getContact() {
          return Contact;
      }
  
      public void setContact(int contact) {
          Contact = contact;
      }
  
      public String getEmail() {
          return Email;
      }
  
      public void setEmail(String email) {
          Email = email;
      }
  
      public Date getDateOfBirth() {
          return DateOfBirth;
      }
  
      public void setDateOfBirth(Date dateOfBirth) {
          DateOfBirth = dateOfBirth;
      }
  
      public Date getDateOfJoining() {
          return DateOfJoining;
      }
  
      public void setDateOfJoining(Date dateOfJoining) {
          DateOfJoining = dateOfJoining;
      }
  
      public int getSalary() {
          return Salary;
      }
  
      public void setSalary(int salary) {
          Salary = salary;
      }
  
  }
  </code></pre>
  
  <p>Controller</p>
  
  <pre><code>    package com.example.crud;
  
  import java.text.SimpleDateFormat;
  import java.util.Map;
  
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.beans.propertyeditors.CustomDateEditor;
  import org.springframework.stereotype.Controller;
  import org.springframework.ui.Model;
  import org.springframework.validation.BindingResult;
  import org.springframework.web.bind.WebDataBinder;
  import org.springframework.web.bind.annotation.InitBinder;
  import org.springframework.web.bind.annotation.ModelAttribute;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  
  import com.example.crud.entities.Users;
  import com.example.crud.service.TaskService;
  
  @Controller
  public class HomeController {
  
      @Autowired
      private TaskService service;
      private Logger logger = LoggerFactory.getLogger(HomeController.class);
  
      @InitBinder
      public void initBinder(WebDataBinder binder){
          System.out.println("exe");
          SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
          sdf.setLenient(true);
          binder.registerCustomEditor(java.sql.Date.class,"DateOfBirth", new CustomDateEditor(sdf, true));
      }
      @RequestMapping(value="/Add", method=RequestMethod.GET)
      public String index(Map&lt;String, Object&gt; model){
          Users users = new Users();
          model.put("users", users);
          logger.debug("users");
          return "home";
      }
  
      @RequestMapping(value="/Register", method=RequestMethod.POST)
      public String Register(@ModelAttribute("users") Users users, BindingResult result, Model model){
          System.out.println(users.getFirst_Name());
          System.out.println(users.getDateOfBirth());
  //      service.Register(users);
          return "home";
      }
  
  }
  </code></pre>