Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
platform
/
finance_serv
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit e2bdac24
authored
Aug 24, 2018
by
王军业
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
12145114
1 parent
219276ec
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
43 deletions
code/finance_serv/src/main/java/com/vion/financial/handler/MilliDateTypeHandler.java
code/finance_serv/src/main/java/com/vion/financial/handler/MilliDateTypeHandler.java
View file @
e2bdac2
package
com
.
vion
.
financial
.
handler
;
import
java.sql.CallableStatement
;
import
java.sql.PreparedStatement
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.util.Date
;
import
org.apache.ibatis.type.BaseTypeHandler
;
import
org.apache.ibatis.type.JdbcType
;
import
org.apache.ibatis.type.MappedJdbcTypes
;
import
org.apache.ibatis.type.MappedTypes
;
@MappedJdbcTypes
({
JdbcType
.
DATE
})
@MappedTypes
({
Date
.
class
})
public
class
MilliDateTypeHandler
extends
BaseTypeHandler
<
Date
>{
@Override
public
void
setNonNullParameter
(
PreparedStatement
ps
,
int
i
,
Date
date
,
JdbcType
jdbcType
)
throws
SQLException
{
//String dateS = DateUtil.FORMAT_YYYY_MM_DD.format(date);
System
.
out
.
println
(
"=======adsa======"
);
java
.
sql
.
Date
sqldate
=
new
java
.
sql
.
Date
(
date
.
getTime
());
ps
.
setDate
(
i
,
sqldate
);
}
@Override
public
Date
getNullableResult
(
ResultSet
rs
,
String
columnName
)
throws
SQLException
{
return
new
Date
(
rs
.
getLong
(
columnName
));
}
@Override
public
Date
getNullableResult
(
ResultSet
rs
,
int
columnIndex
)
throws
SQLException
{
return
new
Date
(
rs
.
getLong
(
columnIndex
));
}
@Override
public
Date
getNullableResult
(
CallableStatement
cs
,
int
columnIndex
)
throws
SQLException
{
return
cs
.
getDate
(
columnIndex
);
}
}
package
com
.
vion
.
financial
.
handler
;
import
java.sql.CallableStatement
;
import
java.sql.PreparedStatement
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.util.Date
;
import
org.apache.ibatis.type.BaseTypeHandler
;
import
org.apache.ibatis.type.JdbcType
;
import
org.apache.ibatis.type.MappedJdbcTypes
;
import
org.apache.ibatis.type.MappedTypes
;
@MappedJdbcTypes
({
JdbcType
.
DATE
})
@MappedTypes
({
Date
.
class
})
public
class
MilliDateTypeHandler
extends
BaseTypeHandler
<
Date
>{
@Override
public
void
setNonNullParameter
(
PreparedStatement
ps
,
int
i
,
Date
date
,
JdbcType
jdbcType
)
throws
SQLException
{
//String dateS = DateUtil.FORMAT_YYYY_MM_DD.format(date);
//System.out.println("=======adsa======");
java
.
sql
.
Date
sqldate
=
new
java
.
sql
.
Date
(
date
.
getTime
());
ps
.
setDate
(
i
,
sqldate
);
}
@Override
public
Date
getNullableResult
(
ResultSet
rs
,
String
columnName
)
throws
SQLException
{
return
new
Date
(
rs
.
getLong
(
columnName
));
}
@Override
public
Date
getNullableResult
(
ResultSet
rs
,
int
columnIndex
)
throws
SQLException
{
return
new
Date
(
rs
.
getLong
(
columnIndex
));
}
@Override
public
Date
getNullableResult
(
CallableStatement
cs
,
int
columnIndex
)
throws
SQLException
{
return
cs
.
getDate
(
columnIndex
);
}
}
Write
Preview
Markdown
is supported
Attach a file
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 post a comment