struts2 json格式日期格式化

在要格式化的属性get方法上加:

@JSON(format="yyyy-MM-dd")

 

class user{
private String userName;
private Date birthDate;

public String getUserName(){
    return this.userName;
}

public void setUserName(String userName){
    this.userName=userName;
}

public void setBirthDate(Date birthDate) {
    this.birthDate=birthDate;
}

@JSON(format="yyyy-MM-dd")
public Date getBirthDate(){
    return this.birthDate;
}
}

 

你可能感兴趣的:(json)