本文整理了Java中org.eclipse.persistence.internal.helper.Helper.truncateDateIgnoreMilliseconds()
方法的一些代码示例,展示了Helper.truncateDateIgnoreMilliseconds()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Helper.truncateDateIgnoreMilliseconds()
方法的具体详情如下:
包路径:org.eclipse.persistence.internal.helper.Helper
类名称:Helper
方法名:truncateDateIgnoreMilliseconds
[英]Return a sql.Date with time component zeroed out (with possible exception of milliseconds). Starting with version 12.1 Oracle jdbc Statement.setDate method no longer zeroes out the whole time component, yet it still zeroes out milliseconds.
[中]返回一个sql。时间组件为零的日期(毫秒除外)。从12.1版Oracle jdbc语句开始。setDate方法不再将整个时间组件归零,但仍将毫秒归零。
代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.oracle
/**
* INTERNAL:
* Note that index (not index+1) is used in statement.setObject(index, parameter)
* Binding starts with a 1 not 0, so make sure that index > 0.
* Treat Calendar separately. Bind Calendar as TIMESTAMPTZ.
*/
@Override
public void setParameterValueInDatabaseCall(Object parameter, PreparedStatement statement, int index, AbstractSession session) throws SQLException {
if (parameter instanceof Calendar) {
Calendar calendar = (Calendar)parameter;
Connection conn = getConnection(session, statement.getConnection());
TIMESTAMPTZ tsTZ = TIMESTAMPHelper.buildTIMESTAMPTZ(calendar, conn, this.shouldPrintCalendar);
statement.setObject(index, tsTZ);
} else if (this.shouldTruncateDate && parameter instanceof java.sql.Date) {
// hours, minutes, seconds all set to zero
statement.setDate(index, Helper.truncateDateIgnoreMilliseconds((java.sql.Date)parameter));
} else {
super.setParameterValueInDatabaseCall(parameter, statement, index, session);
}
}
代码示例来源:origin: com.haulmont.thirdparty/eclipselink
/**
* INTERNAL:
* Note that index (not index+1) is used in statement.setObject(index, parameter)
* Binding starts with a 1 not 0, so make sure that index > 0.
* Treat Calendar separately. Bind Calendar as TIMESTAMPTZ.
*/
@Override
public void setParameterValueInDatabaseCall(Object parameter, PreparedStatement statement, int index, AbstractSession session) throws SQLException {
if (parameter instanceof Calendar) {
Calendar calendar = (Calendar)parameter;
Connection conn = getConnection(session, statement.getConnection());
TIMESTAMPTZ tsTZ = TIMESTAMPHelper.buildTIMESTAMPTZ(calendar, conn, this.shouldPrintCalendar);
statement.setObject(index, tsTZ);
} else if (this.shouldTruncateDate && parameter instanceof java.sql.Date) {
// hours, minutes, seconds all set to zero
statement.setDate(index, Helper.truncateDateIgnoreMilliseconds((java.sql.Date)parameter));
} else {
super.setParameterValueInDatabaseCall(parameter, statement, index, session);
}
}
内容来源于网络,如有侵权,请联系作者删除!