admin
2019-09-29 6f14a131b39c8fc44b29b6130c4e2002bbf2d3ca
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package org.yeshi.utils;
 
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
 
public class GsonUtil {
 
    public static String toDFJson(Object obj) {
 
        return new GsonBuilder().excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create()
                .toJson(obj);
    }
 
    public static String toJson(Object obj) {
        Gson gson = new Gson();
        return gson.toJson(obj);
    }
 
    public static String toJsonExpose(Object obj) {
        Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
        return gson.toJson(obj);
    }
 
}