Gson 格式化JSON日期数据

Google的Gson功能非常强大!

格式化日期我们只需要这样创建就好了

Gson  gson = new GsonBuilder().setDateFormat("yyyy-MM-dd hh:mm:ss).create();

System.out.print(gson.toJson(new Date()));

常见日期格式:

  yyyy-MM-dd

  yyyy-MM-dd hh:mm:ss

  MM-dd-yyyy hh:mm

posted @ 2019-09-01 14:03  Arebirth  阅读(3228)  评论(0编辑  收藏  举报