将java.sql.Time对象注入bean-SpringXML依赖项注入

将java.sql.Time对象注入bean-SpringXML依赖项注入,java,xml,spring,dependency-injection,Java,Xml,Spring,Dependency Injection,我需要使用基于xml的依赖项注入将java.sql.Time对象注入Subjectbean 这是我的主题类定义 public class Subject{ private java.sql.Time startedTime; } 在Java代码中,这就是实现它的方法 Subject subject = new Subject(); Time startedTime = Time.valueOf("HH:MM:SS"); subject.setStartedTime(startedTim

我需要使用基于xml的依赖项注入将
java.sql.Time
对象注入
Subject
bean

这是我的
主题
类定义

public class Subject{
    private java.sql.Time startedTime;
}
在Java代码中,这就是实现它的方法

Subject subject = new Subject();
Time startedTime = Time.valueOf("HH:MM:SS");
subject.setStartedTime(startedTime);
但是现在我需要通过xml在
Subject
bean中注入
Time
对象

<bean id="startedTime" class="mx.com.project.Subject">
<property name="startedTime">
<!-- java.sql.Time injection-->
</property>
</bean>

顺便说一下,

在对象中执行从字符串到时间的转换

public class Subject
{
  private java.sql.Time startedTime;
  // blah.  your stuff.

  public void setStartedTimeValue(final String startedTimeValue)
  {
     startedTime = Time.valueof(startedTimeValue);
  }
}


<bean id="startedTime" class="mx.com.project.Subject">
  <property name="startedTimeValue" value="20:14:37"/>
</bean>
公共类科目
{
private java.sql.Time startedTime;
//等等,你的东西。
public void setStartedTimeValue(最终字符串startedTimeValue)
{
startedTime=Time.valueof(startedTimeValue);
}
}

这个问题的第一个正确答案

    <property name="startedTime">
        <bean factory-method="valueOf" class="java.sql.Time">
            <constructor-arg value="16:00:00" />
        </bean>
    </property>

这似乎是另一种有效的方法。谢谢你的回答
    <property name="startedTime">
        <bean factory-method="valueOf" class="java.sql.Time">
            <constructor-arg value="16:00:00" />
        </bean>
    </property>