package com.whyc.webSocket; import com.google.gson.GsonBuilder; import com.whyc.dto.Response; import javax.websocket.EncodeException; import javax.websocket.Encoder; import javax.websocket.EndpointConfig; /** * 编译器 */ public class WebSocketEncoder implements Encoder.Text { @Override public String encode(Response o) throws EncodeException { return new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create().toJson(o); } @Override public void init(EndpointConfig endpointConfig) { } @Override public void destroy() { } }