Commit 1efc45c0 authored by yanzg's avatar yanzg

消除成功接收处理

parent 80e66d76
......@@ -13,9 +13,13 @@ import java.util.*;
/**
* 对象操作类,包含字段反射
*
* @author 颜佐光
*/
public class ObjectHelper {
public static final String METHOD_IS = "is";
public static final String METHOD_GET = "get";
public static final String METHOD_SET = "set";
/**
* 缓存的类型
*/
......@@ -264,12 +268,12 @@ public class ObjectHelper {
*/
private static String getSimpleName(String fromName) {
String toName = fromName.toLowerCase().replace("_", "");
if (toName.startsWith("is")) {
toName = toName.substring("is".length());
} else if (toName.startsWith("get")) {
toName = toName.substring("get".length());
} else if (toName.startsWith("set")) {
toName = toName.substring("set".length());
if (toName.startsWith(METHOD_IS)) {
toName = toName.substring(METHOD_IS.length());
} else if (toName.startsWith(METHOD_GET)) {
toName = toName.substring(METHOD_GET.length());
} else if (toName.startsWith(METHOD_SET)) {
toName = toName.substring(METHOD_SET.length());
} else {
return toName;
}
......
package com.yanzuoguang.util.helper;
import com.sun.corba.se.spi.presentation.rmi.IDLNameTranslator;
import com.yanzuoguang.util.exception.CodeException;
import com.yanzuoguang.util.exception.ExceptionHelper;
......@@ -12,12 +13,25 @@ import java.util.Date;
/**
* 日期工具类
*
* @author 颜佐光
*/
public class DateHelper {
private static final String FORMAT_DAY_STRING = "yyyy-MM-dd";
private static final String FORMAT_SECOND_STRING = "yyyy-MM-dd HH:mm:ss";
private static final int MONTH_1 = 1;
private static final int MONTH_2 = 2;
private static final int MONTH_3 = 3;
private static final int MONTH_4 = 4;
private static final int MONTH_5 = 5;
private static final int MONTH_6 = 6;
private static final int MONTH_7 = 7;
private static final int MONTH_8 = 8;
private static final int MONTH_9 = 9;
private static final int MONTH_10 = 10;
private static final int MONTH_11 = 11;
private static final int MONTH_12 = 12;
/**
* 获取时间
......@@ -227,14 +241,14 @@ public class DateHelper {
SimpleDateFormat shortSdf = new SimpleDateFormat(FORMAT_DAY_STRING);
Date now = null;
try {
if (currentMonth >= 1 && currentMonth <= 3) {
if (currentMonth >= MONTH_1 && currentMonth <= MONTH_3) {
c.set(Calendar.MONTH, 0);
} else if (currentMonth >= 4 && currentMonth <= 6) {
c.set(Calendar.MONTH, 3);
} else if (currentMonth >= 7 && currentMonth <= 9) {
c.set(Calendar.MONTH, 6);
} else if (currentMonth >= 10 && currentMonth <= 12) {
c.set(Calendar.MONTH, 9);
} else if (currentMonth >= MONTH_4 && currentMonth <= MONTH_6) {
c.set(Calendar.MONTH, MONTH_3);
} else if (currentMonth >= MONTH_7 && currentMonth <= MONTH_9) {
c.set(Calendar.MONTH, MONTH_6);
} else if (currentMonth >= MONTH_10 && currentMonth <= MONTH_12) {
c.set(Calendar.MONTH, MONTH_9);
}
c.set(Calendar.DATE, 1);
now = longSdf.parse(shortSdf.format(c.getTime()) + " 00:00:00");
......
......@@ -21,6 +21,12 @@ public class StringHelper {
* 空字符串常量
*/
public static final String EMPTY = "";
public static final String TYPE_FLOAT = "float";
public static final String TYPE_DOUBLE = "double";
public static final String TYPE_INT = "int";
public static final String TYPE_BOOL = "boolean";
public static final String TYPE_OBJECT = "System.Object";
public static final String UNDER_FLAG = "_";
//------------------------------------------------------ 空值判断和处理 -----------------------------------------------------------------------
......@@ -264,7 +270,7 @@ public class StringHelper {
} else if (type.equals(vBase)) {
return true;
}
if ("System.Object".equals(type.toString())) {
if (TYPE_OBJECT.equals(type.toString())) {
return false;
} else {
return isType(type.getSuperclass(), vBase);
......@@ -289,14 +295,14 @@ public class StringHelper {
to = EnumHelper.toEnum(cls, strValue);
} else if (isType(cls, String.class)) {
to = toString(from);
} else if ("boolean".equals(vName) || isType(cls, Boolean.class)) {
} else if (TYPE_BOOL.equals(vName) || isType(cls, Boolean.class)) {
String strValue = toString(from);
to = toBoolean(strValue);
} else if ("int".equals(vName) || isType(cls, Integer.class)) {
} else if (TYPE_INT.equals(vName) || isType(cls, Integer.class)) {
to = toInt(from);
} else if ("double".equals(vName) || isType(cls, Double.class)) {
} else if (TYPE_DOUBLE.equals(vName) || isType(cls, Double.class)) {
to = toDouble(from);
} else if ("float".equals(vName) || isType(cls, Float.class)) {
} else if (TYPE_FLOAT.equals(vName) || isType(cls, Float.class)) {
to = toDouble(from);
} else if (isType(cls, Double.class)) {
to = toDecimal(from);
......@@ -909,14 +915,14 @@ public class StringHelper {
* 驼峰命名的字符串
*/
public static String getUnderLine(String from) {
if (from.contains("_")) {
if (from.contains(UNDER_FLAG)) {
return from;
}
StringBuilder sb = new StringBuilder();
for (int i = 0; i < from.length(); i++) {
char c = from.charAt(i);
if (Character.isUpperCase(c)) {
sb.append("_");
sb.append(UNDER_FLAG);
}
sb.append(c);
}
......
......@@ -17,6 +17,7 @@ public class ThreadHelper {
private static Date threadDate = null;
private static RunPlan timeout;
private static RunPlan interval;
private static final long SECOND_UNIT = 1000;
/**
* 线程对象
*/
......@@ -95,10 +96,11 @@ public class ThreadHelper {
*/
private static void startMonitor() {
runThread(new Runnable() {
@Override
public void run() {
do {
if (threadIsRun && ((System.currentTimeMillis() - threadDate.getTime()) / 1000) > 5) {
if (threadIsRun && ((System.currentTimeMillis() - threadDate.getTime()) / SECOND_UNIT) > 5) {
try {
if (threadIsRun) {
threadIsRun = false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment