81041
2019-11-18 86397b404b0f18da000b2eb9ad64a5cbedb4cc93
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package com.fgkj.dao;
 
import android.os.Handler;
import android.os.Looper;
import android.webkit.WebView;
 
import com.fgkj.action.ServiceModel;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
 
import java.text.SimpleDateFormat;
import java.util.Date;
 
public class ActionUtil {
 
    public static SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    public static SimpleDateFormat sdfwithOut=new SimpleDateFormat("yyyy-MM-dd");
    
    public static Date getSimpDate(Date time){
        //System.out.println(time);
        return new java.sql.Date(time.getTime());
    }
    /**
     *  返回数据给前台js
     * @param funName
     * @param model
     */
    public static void SendCallDataToJS(String funName, ServiceModel model,WebView webView,Gson gson){
        String call = "javascript:"+funName+"calljs(" + gson.toJson(model) + ")";
        new Handler(Looper.getMainLooper()).post(() -> webView.loadUrl(call));
    }
    /**
     *
     * @param datetype    需要解析的日期的格式如:"yyyy-MM-dd HH:mm:ss"
     * @return    得到对应的gson对象
     */
    public static Gson getGson(String datetype){
        return new  GsonBuilder().setDateFormat(datetype).create();
    }
 
    /**
     * 获取默认的gson对象
     * @return
     */
    public static Gson getGson(){
        return new Gson();
    }
 
}