我正在使用hibernate从oracle Sql Developer数据库中检索数据并使用Spring MVC作为rest api。我在数据库中有2个日期字段。在检索数据时它是JSON格式。日期输出不是DD / MM / YYYY它在Epoch.Here是我的代码:
@RequestMapping(value="{userid}", method = RequestMethod.GET)
public @ResponseBody List<IterationInfo> getIterationInfoInJSON(@PathVariable int userid)
{
Configuration con = new Configuration();
con.configure("hibernate.cfg.xml");
SessionFactory SF = con.buildSessionFactory();
Session session= SF.openSession();
Transaction TR = session.beginTransaction();
Query query=session.createQuery("from IterationInfo");
List<IterationInfo> listiterationinfo=query.list();
session.close();
SF.close();
return listiterationinfo;
}
我认为当我返回listiterationinfo时,它会被转换为Json,因此随后将日期从DD-MM-YY转换为epoch.I希望Json为DD-MM-YYY格式。在数据库中它是DD PoJo / DAO类的-MM-YYYY.Code为
public class IterationInfo
{
private int projectid;
private int iterationid;
private String iterationname;
private Date iterationstartdate;
private Date iterationenddate;
public int getProjectid() {
return projectid;
}
public void setProjectid(int projectid) {
this.projectid = projectid;
}
public int getIterationid() {
return iterationid;
}
public void setIterationid(int iterationid) {
this.iterationid = iterationid;
}
public String getIterationname() {
return iterationname;
}
public void setIterationname(String iterationname) {
this.iterationname = iterationname;
}
public Date getIterationstartdate() {
return iterationstartdate;
}
public void setIterationstartdate(Date iterationstartdate) {
this.iterationstartdate = iterationstartdate;
}
public Date getIterationenddate() {
return iterationenddate;
}
public void setIterationenddate(Date iterationenddate) {
this.iterationenddate = iterationenddate;
}
}
请建议我修改什么。