本文整理匯總了Java中org.hibernate.cfg.Environment.jvmHasTimestampBug方法的典型用法代碼示例。如果您正苦於以下問題:Java Environment.jvmHasTimestampBug方法的具體用法?Java Environment.jvmHasTimestampBug怎麽用?Java Environment.jvmHasTimestampBug使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.hibernate.cfg.Environment
的用法示例。
在下文中一共展示了Environment.jvmHasTimestampBug方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: wrap
import org.hibernate.cfg.Environment; //導入方法依賴的package包/類
public <X> Calendar wrap(X value, WrapperOptions options) {
if ( value == null ) {
return null;
}
if ( Calendar.class.isInstance( value ) ) {
return (Calendar) value;
}
if ( ! Date.class.isInstance( value ) ) {
throw unknownWrap( value.getClass() );
}
Calendar cal = new GregorianCalendar();
if ( Environment.jvmHasTimestampBug() ) {
final long milliseconds = ( (Date) value ).getTime();
final long nanoseconds = java.sql.Timestamp.class.isInstance( value )
? ( (java.sql.Timestamp) value ).getNanos()
: 0;
cal.setTime( new Date( milliseconds + nanoseconds / 1000000 ) );
}
else {
cal.setTime( (Date) value );
}
return cal;
}
示例2: wrap
import org.hibernate.cfg.Environment; //導入方法依賴的package包/類
public <X> Calendar wrap(X value, WrapperOptions options) {
if ( value == null ) {
return null;
}
if ( Calendar.class.isInstance( value ) ) {
return (Calendar) value;
}
if ( ! java.util.Date.class.isInstance( value ) ) {
throw unknownWrap( value.getClass() );
}
Calendar cal = new GregorianCalendar();
if ( Environment.jvmHasTimestampBug() ) {
final long milliseconds = ( (java.util.Date) value ).getTime();
final long nanoseconds = java.sql.Timestamp.class.isInstance( value )
? ( (java.sql.Timestamp) value ).getNanos()
: 0;
cal.setTime( new Date( milliseconds + nanoseconds / 1000000 ) );
}
else {
cal.setTime( (java.util.Date) value );
}
return cal;
}
示例3: get
import org.hibernate.cfg.Environment; //導入方法依賴的package包/類
public Object get(ResultSet rs, String name) throws HibernateException, SQLException {
Timestamp ts = rs.getTimestamp(name);
if (ts!=null) {
Calendar cal = new GregorianCalendar();
if ( Environment.jvmHasTimestampBug() ) {
cal.setTime( new Date( ts.getTime() + ts.getNanos() / 1000000 ) );
}
else {
cal.setTime(ts);
}
return cal;
}
else {
return null;
}
}