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();
|
}
|
|
}
|