Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
C
common
Project
Project
Details
Activity
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
曲欣亮
common
Commits
0b2e1498
Commit
0b2e1498
authored
May 13, 2019
by
Quxl
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://key@gitlab.egolm.com/key/common.git
parents
cb8e9f42
36fdc579
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
1936 additions
and
1815 deletions
+1936
-1815
DateUtil.java
src/main/java/com/egolm/common/DateUtil.java
+38
-2
FileUtil.java
src/main/java/com/egolm/common/FileUtil.java
+596
-575
GsonUtil.java
src/main/java/com/egolm/common/GsonUtil.java
+47
-46
StringUtil.java
src/main/java/com/egolm/common/StringUtil.java
+1140
-1093
SqlServerTo.java
src/main/java/com/egolm/common/jdbc/dialect/SqlServerTo.java
+115
-99
No files found.
src/main/java/com/egolm/common/DateUtil.java
View file @
0b2e1498
...
@@ -29,9 +29,9 @@ public class DateUtil {
...
@@ -29,9 +29,9 @@ public class DateUtil {
public
static
final
String
FMT_DATE_ISO
=
"yyyy-MM-ddTHH:mm:ss.SSSZ"
;
public
static
final
String
FMT_DATE_ISO
=
"yyyy-MM-ddTHH:mm:ss.SSSZ"
;
public
static
final
String
FMT_UTC_GMT
=
"EEE, dd MMM yyyy HH:mm:ss z"
;
public
static
final
String
FMT_UTC_GMT
=
"EEE, dd MMM yyyy HH:mm:ss z"
;
public
static
final
String
FMT_YYYYMMddHHMMSS
=
"yyyyMMddHHmmss"
;
public
static
final
String
FMT_YYYYMMddHHMMSS
=
"yyyyMMddHHmmss"
;
public
static
final
String
FMT_UTC_ALIYUN
=
"
yyyy-MM-dd'T'HH
:mm:ss'Z'"
;
public
static
final
String
FMT_UTC_ALIYUN
=
"
YYYY-MM-DD'T'hh
:mm:ss'Z'"
;
public
static
final
String
FMT_YYYY_MM
=
"yyyy
/
MM"
;
public
static
final
String
FMT_YYYY_MM
=
"yyyy
-
MM"
;
public
static
final
Long
SECOND
=
1000L
;
public
static
final
Long
SECOND
=
1000L
;
public
static
final
Long
MINUTE
=
1000L
*
60
;
public
static
final
Long
MINUTE
=
1000L
*
60
;
...
@@ -448,7 +448,43 @@ public class DateUtil {
...
@@ -448,7 +448,43 @@ public class DateUtil {
}
}
return
null
;
return
null
;
}
}
public
static
String
getLastMonth
(
String
format
,
int
month
)
{
try
{
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
format
);
//获取前一个月第一天
Calendar
calendar1
=
Calendar
.
getInstance
();
calendar1
.
add
(
Calendar
.
MONTH
,
month
);
calendar1
.
set
(
Calendar
.
DAY_OF_MONTH
,
1
);
return
sdf
.
format
(
calendar1
.
getTime
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
public
static
String
getTimeStamp
()
{
public
static
String
getTimeStamp
()
{
return
String
.
valueOf
(
System
.
currentTimeMillis
()
/
1000
);
return
String
.
valueOf
(
System
.
currentTimeMillis
()
/
1000
);
}
}
/**
* 获取指定小时前的日期
*/
public
static
String
beforeHourDay
(
String
fmt
,
int
hour
)
{
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
set
(
Calendar
.
HOUR_OF_DAY
,
calendar
.
get
(
Calendar
.
HOUR_OF_DAY
)
-
hour
);
return
format
(
calendar
.
getTime
(),
fmt
);
}
/**
* 取得当前时间向后或向前若干天的时间
*
* @param time
* @param offset
* @return
*/
public
static
String
beforeDay
(
String
fmt
,
Integer
offset
)
{
Date
date
=
new
Date
(
new
Date
().
getTime
()
+
(
offset
*
86400000L
));
return
format
(
date
,
fmt
);
}
}
}
src/main/java/com/egolm/common/FileUtil.java
View file @
0b2e1498
...
@@ -572,5 +572,26 @@ public class FileUtil {
...
@@ -572,5 +572,26 @@ public class FileUtil {
}
}
}
}
public
static
Object
fileToObject
(
File
file
)
{
FileInputStream
fis
=
null
;
ObjectInputStream
ois
=
null
;
try
{
fis
=
new
FileInputStream
(
file
);
ois
=
new
ObjectInputStream
(
fis
);
return
ois
.
readObject
();
}
catch
(
FileNotFoundException
e
)
{
throw
new
FileUtilException
(
e
);
}
catch
(
IOException
e
)
{
throw
new
FileUtilException
(
e
);
}
catch
(
ClassNotFoundException
e
)
{
throw
new
FileUtilException
(
e
);
}
finally
{
try
{
ois
.
close
();
fis
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
}
}
\ No newline at end of file
src/main/java/com/egolm/common/GsonUtil.java
View file @
0b2e1498
package
com
.
egolm
.
common
;
package
com
.
egolm
.
common
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
...
src/main/java/com/egolm/common/StringUtil.java
View file @
0b2e1498
...
@@ -1090,4 +1090,51 @@ public class StringUtil {
...
@@ -1090,4 +1090,51 @@ public class StringUtil {
}
}
return
out
.
toString
();
return
out
.
toString
();
}
}
/**
*
* @Description 字节数组转16进制字符串
* @param bytes
* @return
* @author 曲欣亮
* @date 2016年4月25日
* @since 2016年4月25日
* @return String
* @throws
*/
public
static
String
bytesToHex
(
byte
[]
bytes
)
{
return
Hex
.
encodeHexString
(
bytes
);
}
/**
*
* @描述:是否是2003的excel,返回true是2003
*
*
* @参数:@param filePath 文件完整路径
*
* @参数:@return
*
* @返回值:boolean
*/
public
static
boolean
isExcel2003
(
String
filePath
){
return
filePath
.
matches
(
"^.+\\.(?i)(xls)$"
);
}
/**
*
* @描述:是否是2007的excel,返回true是2007
*
*
* @参数:@param filePath 文件完整路径
*
* @参数:@return
*
* @返回值:boolean
*/
public
static
boolean
isExcel2007
(
String
filePath
){
return
filePath
.
matches
(
"^.+\\.(?i)(xlsx)$"
);
}
}
}
src/main/java/com/egolm/common/jdbc/dialect/SqlServerTo.java
View file @
0b2e1498
...
@@ -52,6 +52,22 @@ public class SqlServerTo {
...
@@ -52,6 +52,22 @@ public class SqlServerTo {
}
}
}
}
public
void
executeView
()
{
try
{
String
sql
=
"SELECT TABLE_NAME , 'REMARK' AS TABLE_COMMENT FROM INFORMATION_SCHEMA.VIEWS"
;
PreparedStatement
pStemt
=
conn
.
prepareStatement
(
sql
);
ResultSet
set
=
pStemt
.
executeQuery
();
while
(
set
.
next
())
{
String
name
=
set
.
getString
(
"TABLE_NAME"
).
trim
();
String
comment
=
set
.
getString
(
"TABLE_COMMENT"
);
execute
(
name
,
comment
);
}
conn
.
close
();
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
}
}
public
void
executeFilter
(
String
sign
)
{
public
void
executeFilter
(
String
sign
)
{
try
{
try
{
String
sql
=
"SELECT D.name AS TABLE_NAME, 'REMARK' AS TABLE_COMMENT FROM sysobjects AS D WHERE D.XTYPE = 'U' AND D.NAME <> 'dtproperties'"
;
String
sql
=
"SELECT D.name AS TABLE_NAME, 'REMARK' AS TABLE_COMMENT FROM sysobjects AS D WHERE D.XTYPE = 'U' AND D.NAME <> 'dtproperties'"
;
...
...
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