model

public class ResponseModel {

    private Exception exception;

    private ResponseCode code;

    private Integer error;

    private String message;

   private String serverTime;

    private Long time;

    private Object data;

    private String msg;

....//省去set  /get



    @Override

    public String toString() {
        this.setTime(new Date().getTime() - this.getTime());
 this.setServerTime(DateToString(new Date(), "yyyy-MM-dd HH:mm:ss.SSS"));
      return JSON.toJSONString(this);
    }

 //转化时间
   public static String DateToString(Date date, String format) {
     date = (date == null ? new Date(0) : date);
  format = (Strings.isNullOrEmpty(format) ? "yyyy-MM-dd HH:mm:ss" : format.trim());
      SimpleDateFormat sdf = new SimpleDateFormat(format);
  return sdf.format(date);

    }
}

你可能感兴趣的:(model)