【问题标题】:Change the Date Default Format in Jettison更改 Jettison 中的日期默认格式
【发布时间】:2012-09-14 19:08:04
【问题描述】:

Jettison 库返回的默认日期格式可以更改吗?

这是默认的日期格式

{ “邮政”: { "activityDate": "2012-07-03T16:15:29.111-04:00", "modfiedDate": "2012-07-03T16:15:29.111-04:00", "createdDate": "2012-07-03T16:15:29.111-04:00" } }

可以改吗?

我们可以在 Jakson 中使用 org.codehaus.jackson.map.JsonSerialize 注解来做到这一点。

如何在 Jettison 中做到这一点?

Jettison 有类似的类吗?

谢谢

【问题讨论】:

    标签: jackson jettison


    【解决方案1】:

    这可以使用 XMLAdapters 来完成

    公共类 DateAdapter 扩展 XmlAdapter {

    /**
     * This method is called when we return the DTO Date property to UI, We
     * convert the date to UI  date format
     */
    @Override
    public String marshal(Date inputDate) throws Exception {
    
        .........
    
        return dateStr;
    }
    
    /**
     * This method is called when UI sends date String and we set the DTO Date
     * property
     */
    @Override
    public Date unmarshal(String inputDateStr) throws Exception {
                ................
        return inputdate;
    }
    

    }

    【讨论】:

      猜你喜欢
      • 2016-01-25
      • 1970-01-01
      • 2019-05-29
      • 1970-01-01
      • 1970-01-01
      • 2017-08-28
      • 1970-01-01
      • 2011-03-09
      • 1970-01-01
      相关资源
      最近更新 更多