whyclxw
2024-08-13 cd894a2b7742b4b275133c3beb3d1a25baf9b66a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package com.whyc.util;
 
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
 
public class JsonUtil {
 
    /**
     *
     * @param dataType    需要解析的日期的格式如:"yyyy-MM-dd HH:mm:ss"
     * @return    得到对应的gson对象
     */
    public static Gson getGson(String dataType){
        return new GsonBuilder().setDateFormat(dataType).create();
    }
 
    /**
     * 获取默认的gson对象
     * @return
     */
    public static Gson getGson(){
        return new Gson();
    }
 
}