Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
Y
yzg-util
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
YZG
yzg-util
Commits
1efc45c0
Commit
1efc45c0
authored
May 07, 2019
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
消除成功接收处理
parent
80e66d76
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
21 deletions
+47
-21
ObjectHelper.java
...src/main/java/com/yanzuoguang/util/base/ObjectHelper.java
+10
-6
DateHelper.java
...src/main/java/com/yanzuoguang/util/helper/DateHelper.java
+21
-7
StringHelper.java
...c/main/java/com/yanzuoguang/util/helper/StringHelper.java
+13
-7
ThreadHelper.java
...c/main/java/com/yanzuoguang/util/thread/ThreadHelper.java
+3
-1
No files found.
yzg-util-base/src/main/java/com/yanzuoguang/util/base/ObjectHelper.java
View file @
1efc45c0
...
...
@@ -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
;
}
...
...
yzg-util-base/src/main/java/com/yanzuoguang/util/helper/DateHelper.java
View file @
1efc45c0
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"
);
...
...
yzg-util-base/src/main/java/com/yanzuoguang/util/helper/StringHelper.java
View file @
1efc45c0
...
...
@@ -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
);
}
...
...
yzg-util-base/src/main/java/com/yanzuoguang/util/thread/ThreadHelper.java
View file @
1efc45c0
...
...
@@ -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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment