线上Bug记录

Gson序列化日期问题:
Gson在linux服务器如果序列化的字段有日期记得要添加日期格式化。

public static Gson buildCommonGson() {
        Gson gson = new GsonBuilder()
                .registerTypeAdapter(int.class, new IntTypeAdapter())
                .registerTypeAdapter(Integer.class, new IntTypeAdapter())
                .registerTypeAdapter(double.class, new DoubleTypeAdapter())
                .registerTypeAdapter(Double.class, new DoubleTypeAdapter())
                .registerTypeAdapter(long.class, new LongTypeAdapter())
                .registerTypeAdapter(Long.class, new LongTypeAdapter())
                .setDateFormat("yyyy-MM-dd HH:mm:ss")
                .create();
        return gson;
    }

签名问题:
编写签名的时候一定要指定签名编码
String nowSign = MD5.create().digestHex(json.toString(), "UTF-8");
否则联调容易出现签名失败,可能就是因为编码不一致导致的

posted @ 2022-03-24 17:46  哦哈呦  阅读(16)  评论(0)    收藏  举报