EWA DEMO emp-script emp-script-utils emp-script-static ffmpeg-utils weixin

更新 com.gdxsoft.easyweb.datasource.DataConnection 的日期表达式

2016-05-23

包:com.gdxsoft.easyweb.datasource.DataConnection

处理ListFrame的日期查询的参数问题,首先将字符串处理为日期型,然后根据数据库类型转换为SQL日期表达式

/**
 * 获取ListFrame查询的日期表达式
 * 
 * @param s1
 * @return
 */
public String getDateTimePara(String s1) {
    if (s1 == null || s1.trim().length() == 0) {
        return null;
    }
    String s2 = s1.replace("'", "");
    // 先获取字符串的转换的 yyyy-mm-dd表达式
    s2 = Utils.getDateTimeString(new Date(this.getTimestamp(s2).getTime()));
    if (this._DatabaseType.equals("ORACLE") || this._DatabaseType.equals("HSQLDB")) {
        return "to_date('" + s2 + "','YYYY-MM-DD')";
    } else {
        return "'" + s2 + "'";
    }
}

private java.sql.Timestamp getTimestamp(String s1) {
    if (s1.indexOf(":") < 1) {
        s1 = s1 + " 00:00:00.0000";
    } else {
        String[] s2 = s1.split(":");
        if (s2.length == 2) {
            s1 += ":00.0000";
        } else if (s2.length == 3 && s1.indexOf(".") == -1) {
            s1 += ".0000";
        }
    }
    try {
        if (this._RequestValue != null && this._RequestValue.getString("ewa_lang") != null
                && this._RequestValue.getString("ewa_lang").toUpperCase().equals("ENUS")) {
            // usa标准
            String[] s2 = s1.split(" ");
            String[] s3 = s2[0].split("\\/");
            if (s3.length != 3) {
                return null;
            }
            if (this._RequestValue != null && this._RequestValue.getString("SYS_EWA_ENUS_YMD") != null
                    && this._RequestValue.getString("SYS_EWA_ENUS_YMD").toLowerCase().equals("dd/mm/yyyy")) {
                //英式日期表达式
                s1 = s3[2] + "-" + s3[1] + "-" + s3[0] + " " + s2[1];
            } else {
                //美式日期表达式
                s1 = s3[2] + "-" + s3[0] + "-" + s3[1] + " " + s2[1];
            }
    
        }
        java.sql.Timestamp t1 = java.sql.Timestamp.valueOf(s1);
        return t1;
    } catch (Exception e) {
        return null;
    }
}