title: Dependency Injection for Date Object
body: <p>I am try to DI a Date object</p>
  
  <p>here's the code for the xml file</p>
  
  <pre><code>&lt;bean id="date" class="java.util.Date"/&gt;
  &lt;bean id="obj"   class="com.Person.Implementor" autowire="byName"&gt;
      &lt;property name="username"&gt;&lt;value&gt;Abc&lt;/value&gt;&lt;/property&gt;
      &lt;property name="password"&gt;&lt;value&gt;password&lt;/value&gt;&lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>Here's the class:</p>
  
  <pre><code>package com.Person;
  import java.util.Date;
  import org.springframework.beans.factory.annotation.Autowired;
  public class Implementor {
  
  String username;
  String password;
  
  Date date;
  
  public Date getDate() {
      return date;
  }
  
  @Autowired
  public void setDate(Date date) {
      this.date = date;
  }
  
  @Override
  public String toString() {
      return "Implementor [username=" + username + ", password=" + password
              + ", date=" + date + "]";
  }
  
  
  public String getUsername() {
      return username;
  }
  public void setUsername(String username) {
      this.username = username;
  }
  public String getPassword() {
      return password;
  }
  public void setPassword(String password) {
      this.password = password;
  }
  
  }
  </code></pre>
  
  <p>But it doesnt seem to work, the Date reference seems to have the NULL value while printing, it works fine for custom created classes tough</p>
  
  <p>Update: Got a reply for Spring support form:
  <a href="http://forum.springsource.org/showthread.php?127017-Dependancy-Injection-for-Date-Object&amp;p=414519#post414519" rel="nofollow">http://forum.springsource.org/showthread.php?127017-Dependancy-Injection-for-Date-Object&amp;p=414519#post414519</a></p>
  
  <p>"This is by Spring design. Spring does not do auto-wiring for "simple" properties, e.g. primitives, Strings and Date. But i don't see a good reason for you to auto-wire bean with Date type. "</p>