Java Code Examples for com.alipay.api.AlipayConstants#DATE_TIME_FORMAT

The following examples show how to use com.alipay.api.AlipayConstants#DATE_TIME_FORMAT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AlipayHashMap.java    From alipay-sdk-java-all with Apache License 2.0 5 votes vote down vote up
public String put(String key, Object value) {
    String strValue;

    if (value == null) {
        strValue = null;
    } else if (value instanceof String) {
        strValue = (String) value;
    } else if (value instanceof Integer) {
        strValue = ((Integer) value).toString();
    } else if (value instanceof Long) {
        strValue = ((Long) value).toString();
    } else if (value instanceof Float) {
        strValue = ((Float) value).toString();
    } else if (value instanceof Double) {
        strValue = ((Double) value).toString();
    } else if (value instanceof Boolean) {
        strValue = ((Boolean) value).toString();
    } else if (value instanceof Date) {
        DateFormat format = new SimpleDateFormat(AlipayConstants.DATE_TIME_FORMAT);
        format.setTimeZone(TimeZone.getTimeZone(AlipayConstants.DATE_TIMEZONE));
        strValue = format.format((Date) value);
    } else {
        strValue = value.toString();
    }

    return this.put(key, strValue);
}
 
Example 2
Source File: AlipayLogger.java    From alipay-sdk-java-all with Apache License 2.0 5 votes vote down vote up
/**
 * 通讯错误日志
 */
private static void _logCommError(Exception e, HttpURLConnection conn, String url,
                                  String appKey, String method, Map<String, String> params) {
    DateFormat df = new SimpleDateFormat(AlipayConstants.DATE_TIME_FORMAT);
    df.setTimeZone(TimeZone.getTimeZone(AlipayConstants.DATE_TIMEZONE));
    String sdkName = AlipayConstants.SDK_VERSION;
    String urlStr = null;
    String rspCode = "";
    if (conn != null) {
        try {
            urlStr = conn.getURL().toString();
            rspCode = "HTTP_ERROR_" + conn.getResponseCode();
        } catch (IOException ioe) {
        }
    } else {
        urlStr = url;
        rspCode = "";
    }
    StringBuilder sb = new StringBuilder();
    sb.append(df.format(new Date()));// 时间
    sb.append("^_^");
    sb.append(method);// API
    sb.append("^_^");
    sb.append(appKey);// APP
    sb.append("^_^");
    sb.append(getIp());// IP地址
    sb.append("^_^");
    sb.append(osName);// 操作系统
    sb.append("^_^");
    sb.append(sdkName);// SDK名字,这是例子,请换成其他名字
    sb.append("^_^");
    sb.append(urlStr);// 请求URL
    sb.append("^_^");
    sb.append(rspCode);
    sb.append("^_^");
    sb.append((e.getMessage() + "").replaceAll("\r\n", " "));
    clog.error(sb.toString());
}
 
Example 3
Source File: AlipayHashMap.java    From alipay-sdk with Apache License 2.0 5 votes vote down vote up
public String put(String key, Object value) {
	String strValue;

	if (value == null) {
		strValue = null;
	} else if (value instanceof String) {
		strValue = (String) value;
	} else if (value instanceof Integer) {
		strValue = ((Integer) value).toString();
	} else if (value instanceof Long) {
		strValue = ((Long) value).toString();
	} else if (value instanceof Float) {
		strValue = ((Float) value).toString();
	} else if (value instanceof Double) {
		strValue = ((Double) value).toString();
	} else if (value instanceof Boolean) {
		strValue = ((Boolean) value).toString();
	} else if (value instanceof Date) {
           DateFormat format = new SimpleDateFormat(AlipayConstants.DATE_TIME_FORMAT);
           format.setTimeZone(TimeZone.getTimeZone(AlipayConstants.DATE_TIMEZONE));
		strValue = format.format((Date) value);
	} else {
		strValue = value.toString();
	}

	return this.put(key, strValue);
}
 
Example 4
Source File: AlipayLogger.java    From alipay-sdk with Apache License 2.0 5 votes vote down vote up
/**
 * 通讯错误日志
 */
private static void _logCommError(Exception e, HttpURLConnection conn, String url,
                                  String appKey, String method, Map<String, String> params) {
    DateFormat df = new SimpleDateFormat(AlipayConstants.DATE_TIME_FORMAT);
    df.setTimeZone(TimeZone.getTimeZone(AlipayConstants.DATE_TIMEZONE));
    String sdkName = AlipayConstants.SDK_VERSION;
    String urlStr = null;
    String rspCode = "";
    if (conn != null) {
        try {
            urlStr = conn.getURL().toString();
            rspCode = "HTTP_ERROR_" + conn.getResponseCode();
        } catch (IOException ioe) {
        }
    } else {
        urlStr = url;
        rspCode = "";
    }
    StringBuilder sb = new StringBuilder();
    sb.append(df.format(new Date()));// 时间
    sb.append("^_^");
    sb.append(method);// API
    sb.append("^_^");
    sb.append(appKey);// APP
    sb.append("^_^");
    sb.append(getIp());// IP地址
    sb.append("^_^");
    sb.append(osName);// 操作系统
    sb.append("^_^");
    sb.append(sdkName);// SDK名字,这是例子,请换成其他名字
    sb.append("^_^");
    sb.append(urlStr);// 请求URL
    sb.append("^_^");
    sb.append(rspCode);
    sb.append("^_^");
    sb.append((e.getMessage() + "").replaceAll("\r\n", " "));
    clog.error(sb.toString());
}
 
Example 5
Source File: AlipayHashMap.java    From pay with Apache License 2.0 5 votes vote down vote up
public String put(String key, Object value) {
	String strValue;

	if (value == null) {
		strValue = null;
	} else if (value instanceof String) {
		strValue = (String) value;
	} else if (value instanceof Integer) {
		strValue = ((Integer) value).toString();
	} else if (value instanceof Long) {
		strValue = ((Long) value).toString();
	} else if (value instanceof Float) {
		strValue = ((Float) value).toString();
	} else if (value instanceof Double) {
		strValue = ((Double) value).toString();
	} else if (value instanceof Boolean) {
		strValue = ((Boolean) value).toString();
	} else if (value instanceof Date) {
           DateFormat format = new SimpleDateFormat(AlipayConstants.DATE_TIME_FORMAT);
           format.setTimeZone(TimeZone.getTimeZone(AlipayConstants.DATE_TIMEZONE));
		strValue = format.format((Date) value);
	} else {
		strValue = value.toString();
	}

	return this.put(key, strValue);
}
 
Example 6
Source File: AlipayLogger.java    From pay with Apache License 2.0 5 votes vote down vote up
private static void _logCommError(Exception e, HttpURLConnection conn, String url,
                                  String appKey, String method, Map<String, String> params) {
    DateFormat df = new SimpleDateFormat(AlipayConstants.DATE_TIME_FORMAT);
    df.setTimeZone(TimeZone.getTimeZone(AlipayConstants.DATE_TIMEZONE));
    String sdkName = AlipayConstants.SDK_VERSION;
    String urlStr = null;
    String rspCode = "";
    if (conn != null) {
        try {
            urlStr = conn.getURL().toString();
            rspCode = "HTTP_ERROR_" + conn.getResponseCode();
        } catch (IOException ioe) {
        }
    } else {
        urlStr = url;
        rspCode = "";
    }
    StringBuilder sb = new StringBuilder();
    sb.append(df.format(new Date()));// 时间
    sb.append("^_^");
    sb.append(method);// API
    sb.append("^_^");
    sb.append(appKey);// APP
    sb.append("^_^");
    sb.append(getIp());// IP地址
    sb.append("^_^");
    sb.append(osName);// 操作系统
    sb.append("^_^");
    sb.append(sdkName);// SDK名字,这是例子,请换成其他名字
    sb.append("^_^");
    sb.append(urlStr);// 请求URL
    sb.append("^_^");
    sb.append(rspCode);
    sb.append("^_^");
    sb.append((e.getMessage() + "").replaceAll("\r\n", " "));
    clog.error(sb.toString());
}