已定义jsonField,dataFormat="yyyy-MM-ddTHH:mm:ss.000Z",返回数据还是:2016-07-05 15:06:03
@JsonField(dataFormat="yyyy-MM-ddTHH:mm:ss.000Z")
private java.util.Date createTime;
你写的根本没法pass啊, 应该是这样, 需要带单引号.
@JsonField(dataFormat="yyyy-MM-dd'T'HH:mm:ss.000Z")
private java.util.Date createTime;
不行,返回的数据格式还是:2016-07-05 15:06:03
@JsonField(dataFormat="yyyy-MM-dd'T'HH:mm:ss.000Z")
private java.util.Date createTime;
修改为:@JsonField(dataFormat="yyyy-MM-dd'T'HH:mm:ss'.000Z'") 也不行
实体类
@Table("sm_evaluate")
public class Evaluate {
@Name
@Column("fid")
private String id;
@Column("version")
private int version;
@Column("fcustomerid")
private String customerID;
@Column("fproductid")
private String productID;
@Column("fgrade")
private int grade;
@Column("fcontent")
private String content;
@Column("fvalidstate")
private int validState;
@Column("screatetime")
@JsonField(dataFormat="yyyy-MM-dd'T'HH:mm:ss'.000Z'")
private java.util.Date createTime;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public int getVersion() {
return version;
}
public void setVersion(int version) {
this.version = version;
}
public String getCustomerID() {
return customerID;
}
public void setCustomerID(String customerID) {
this.customerID = customerID;
}
public String getProductID() {
return productID;
}
public void setProductID(String productID) {
this.productID = productID;
}
public int getGrade() {
return grade;
}
public void setGrade(int grade) {
this.grade = grade;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public int getValidState() {
return validState;
}
public void setValidState(int validState) {
this.validState = validState;
}
public java.util.Date getCreateTime() {
return createTime;
}
public void setCreateTime(java.util.Date createTime) {
this.createTime = createTime;
}
}
action
@At("/zlz/sell/evaluate")
@IocBean
public class EvaluateAction {
@Inject
private Dao dao;
@At("/my")
@Ok("json")
@AdaptBy(type = JsonAdaptor.class)
public JSONObject my(@Param("..") JSONObject params) {
String userid = params.getString("userid");
Integer limit = params.getInteger("limit");
Integer offset = params.getInteger("offset");
Pager pager = new Pager();
pager.setPageNumber((int) (offset / limit));
pager.setPageSize(limit);
Sql sql = Sqls.create(" select a.*,b.fName,b.fSpec,b.fAssist,b.fAssistText,b.fImage from SM_evaluate a left join PR_product b on b.fID =a.fProductID where a.fCustomerID =@userid ");
sql.setParam("userid", userid);
sql.setPager(pager);
sql.setCallback(Sqls.callback.records());
dao.execute(sql);
List<Record> rows = sql.getList(Record.class);
JSONObject table = new JSONObject();
table.put("@type", "table");// 设置type
table.put("rows", rows);// rows
JSONObject userdata = new JSONObject();
// userdata.put("sys.count", pager.getRecordCount());
table.put("userdata", userdata);// 设置userdata
return table;
}
public static void main(String[] args) {
Date date =new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'.000Z'");
System.out.println(sdf.format(date));
}
}
已record方式返回数据,主要代码片断
Sql sql = Sqls.create(" select a.*,b.fName,b.fSpec,b.fAssist,b.fAssistText,b.fImage from SM_evaluate a left join PR_product b on b.fID =a.fProductID where a.fCustomerID =@userid ");
sql.setParam("userid", userid);
sql.setPager(pager);
sql.setCallback(Sqls.callback.records());
dao.execute(sql);
List<Record> rows = sql.getList(Record.class);