@Override public String toString() { return JSON.toJSONStringWithDateFormat(this, "yyyy-MM-dd HH:mm:ss"); }
public String toJson(Object object) { // 优先使用对象级的属性 datePattern, 然后才是全局性的 defaultDatePattern String dp = datePattern != null ? datePattern : getDefaultDatePattern(); if (dp == null) { return JSON.toJSONString(object); } else { return JSON.toJSONStringWithDateFormat(object, dp, SerializerFeature.WriteDateUseDateFormat); // return JSON.toJSONString(object, SerializerFeature.WriteDateUseDateFormat); } }
/** * 将对象解析为字符串 */ public static final String toJSONString(Object object) { return JSON.toJSONStringWithDateFormat(object, DEFFAULT_DATE_FORMAT, serializerFeature); }
private String jsonizeNodeInfo(NodeInfo nodeInfo) { String dateFormat = "yyyy-MM-dd HH:mm:ss"; return JSON.toJSONStringWithDateFormat(nodeInfo, dateFormat, SerializerFeature.WriteDateUseDateFormat); } }
public static String toJSONString(Object obj) { return JSON.toJSONStringWithDateFormat(obj, "yyyy-MM-dd HH:mm:ss", SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullBooleanAsFalse, SerializerFeature.WriteNullListAsEmpty, SerializerFeature.WriteNullNumberAsZero, SerializerFeature.WriteNullStringAsEmpty, SerializerFeature.DisableCircularReferenceDetect ); } }
public static String toJSONStringWithDateFormat(Date paramDate, String paramString) { return JSON.toJSONStringWithDateFormat(paramDate, paramString, new SerializerFeature[]{SerializerFeature.WriteDateUseDateFormat}); }
@Override public String toString() { return JSON.toJSONStringWithDateFormat(this, "yyyy-MM-dd HH:mm:ss"); }
/** * toString * * @date 2018/8/9 下午3:33 * @param: [] * @return: java.lang.String */ @Override public String toString() { return JSON.toJSONStringWithDateFormat(this, DateFormatUtils.PATTERN_DEFAULT_ON_SECOND); }
/** * toString * * @date 2018/8/9 下午3:33 * @param: [] * @return: java.lang.String */ @Override public String toString() { return JSON.toJSONStringWithDateFormat(this, DateFormatUtils.PATTERN_DEFAULT_ON_SECOND); }
@Override public String toString() { return JSON.toJSONStringWithDateFormat(this, DateTimeUtils.YEAR_MONTH_DAY_HOUR_MINUTE_SECOND); }
public static String toJson(Object value) { return JSON.toJSONStringWithDateFormat(value, "yyyy-MM-dd HH:mm:ss"); }
public static String toJson(Object value, String dateFormat) { return JSON.toJSONStringWithDateFormat(value, dateFormat); }
public static String toJSONStringWithDateFormat(Date paramDate) { return JSON.toJSONStringWithDateFormat(paramDate, "yyyy-MM-dd HH:mm:ss", new SerializerFeature[]{SerializerFeature.WriteDateUseDateFormat}); }
public static <T> String toJson(T object) { if (object == null) { throw new SerializerException("Object is null"); } return JSON.toJSONStringWithDateFormat(object, ThunderConstant.DATE_FORMAT, SerializerFeature.WriteClassName); }
public String toJson(Object object) { // 优先使用对象级的属性 datePattern, 然后才是全局性的 defaultDatePattern String dp = datePattern != null ? datePattern : getDefaultDatePattern(); if (dp == null) { return JSON.toJSONString(object); } else { return JSON.toJSONStringWithDateFormat(object, dp, SerializerFeature.WriteDateUseDateFormat); // return JSON.toJSONString(object, SerializerFeature.WriteDateUseDateFormat); } }
/** * Bean对象转JSON * * @param object * @param dataFormatString * @return */ public static String beanToJson(Object object, String dataFormatString) { if (object != null) { if (StringUtils.isEmpty(dataFormatString)) { return JSONObject.toJSONString(object); } return JSON.toJSONStringWithDateFormat(object, dataFormatString); } else { return null; } }
public static void toJson(){ /** * 单个对象 */ Person person = BeanData.randPerson(); PrintUtils.print("Person 对象序列化为 JSON 字符串", JSON.toJSONString(person)); /** * List对象 */ List<Person> persons = BeanData.randPersons(5); PrintUtils.print("Person 列表序列化为 JSON 字符串", JSON.toJSONString(persons)); /** * 使用单引号 */ PrintUtils.print("使用单引号", JSON.toJSONString(person, SerializerFeature.UseSingleQuotes)); /** * 日期格式化 */ PrintUtils.print("日期格式化", JSON.toJSONString(person, SerializerFeature.WriteDateUseDateFormat)); /** * 指定日期格式 */ PrintUtils.print("指定日期格式", JSON.toJSONStringWithDateFormat(person, "yyyy年MM月dd日")); }
String urib = "http://" + instance.getHost() + ":" + instance.getPort() + "/add/" + a; Integer methodb = 1; String edateb = JSON.toJSONStringWithDateFormat(new Date(), "yyyy-MM-dd HH:mm:ss.SSS"); Integer etypeb = 1; // bapp etype = 1 BAPP start, 2ok 3:need String edatea = JSON.toJSONStringWithDateFormat(new Date(), "yyyy-MM-dd HH:mm:ss.SSS"); String uria = "http://localhost:2220/add1/{a}?pevh={pevh}"; String eresponse = JSONObject.toJSONString(ReturnResult.class); b.setId(66l); Integer etypec = 5; String edatec = JSON.toJSONStringWithDateFormat(new Date(), "yyyy-MM-dd HH:mm:ss.SSS"); String uric = "http://localhost:2220/add2/{ids}"; String parematerc = JSON.toJSONString(b, SerializerFeature.WriteClassName); edatec = JSON.toJSONStringWithDateFormat(new Date(), "yyyy-MM-dd HH:mm:ss.SSS"); rs = 2; edateb = JSON.toJSONStringWithDateFormat(new Date(), "yyyy-MM-dd HH:mm:ss.SSS"); thelp.send(rabbitTemplate,restTemplate, serviceNumber, 0, pathParematerb, bid, 1, eresponseb, urib, bapp, null, etypeb, methodb, null, edateb, 1); if (rs == 1) {