`
chj738871937
  • 浏览: 18727 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

java对象与json字符串转换

阅读更多
Date date = new Date();
JSONObject dataJsonObj = JSONObject.fromObject(date);
String dataJsonStr = dataJsonObj.toString();
System.out.println(dataJsonStr);
		
JSONObject jsonObj = JSONObject.fromObject(dataJsonStr);
Date myDate = (Date) JSONObject.toBean(jsonObj, Date.class);
System.out.println(myDate);
DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.LONG);
String myDateStr = dateFormat.format(myDate);
System.out.println(myDateStr);
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics