Share on Google+Share on Google+

Spring Date Editor, Spring Date Property Editor

In this tutorial you will see an example of a Spring Date Editor.

Spring Date Editor, Spring Date Property Editor

Passing a date format in the bean property is not allowed and in order to do so you need to declare a CustomDateEditor class for converting the String into java.util.Date properties.


import java.util.Date;

public class Employee {

	private Date joiningDate;
	private String name;

	public Date getJoiningDate() {
		return joiningDate;

	public void setJoiningDate(Date joiningDate) {
		this.joiningDate = joiningDate;

	public String getName() {
		return name;

	public void setName(String name) { = name;



import org.springframework.context.ApplicationContext;

public class AppMain {
	public static void main(String[] args) {
		ApplicationContext context = new ClassPathXmlApplicationContext(
				new String[] { "context.xml" });
		Employee emp = (Employee) context.getBean("bean1");


<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=""
  xmlns:xsi="" xmlns:aop=""

<bean id="dateEditor"
    <bean class="java.text.SimpleDateFormat">
      <constructor-arg value="yyyy-MM-dd" />
  <constructor-arg value="true" />

  <bean id="bean1" class="">
    <property name="name" value="Rakesh" />
    <property name="joiningDate" value="1/09/2010" />


When you run this application it will display message as shown below:

Wed Sep 01 00:00:00 GMT+05:30 2010

Download this example code


Posted on: September 1, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.


Advertisement null