本文整理了Java中org.eclipse.persistence.internal.helper.Helper.timestampFromString()
方法的一些代码示例,展示了Helper.timestampFromString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Helper.timestampFromString()
方法的具体详情如下:
包路径:org.eclipse.persistence.internal.helper.Helper
类名称:Helper
方法名:timestampFromString
[英]Answer a Timestamp from a string representation. This method will accept strings in the following formats: YYYY/MM/DD HH:MM:SS, YY/MM/DD HH:MM:SS, YYYY-MM-DD HH:MM:SS, YY-MM-DD HH:MM:SS
[中]从字符串表示中回答时间戳。此方法将接受以下格式的字符串:YYYY/MM/DD HH:MM:SS、YY/MM/DD HH:MM:SS、YYYY-MM-DD HH:MM:SS、YY-MM-DD HH:MM:SS
代码示例来源:origin: com.haulmont.thirdparty/eclipselink
DatabaseQuery applyToDatabaseQuery(Object valueToApply, DatabaseQuery query, ClassLoader loader, AbstractSession activeSession) {
if (query.isObjectLevelReadQuery()) {
((ObjectLevelReadQuery) query).setAsOfClause(new AsOfClause(Helper.timestampFromString((String)valueToApply)));
} else {
throw new IllegalArgumentException(ExceptionLocalization.buildMessage("ejb30-wrong-type-for-query-hint",new Object[]{getQueryId(query), name, getPrintValue(valueToApply)}));
}
return query;
}
}
代码示例来源:origin: com.haulmont.thirdparty/eclipselink
/**
* INTERNAL:
* Build a valid instance of java.util.Date from the given source object.
* @param sourceObject Valid instance of java.util.Date, String, java.sql.Timestamp, or Long
*/
protected java.util.Date convertObjectToUtilDate(Object sourceObject) throws ConversionException {
java.util.Date date = null;
if (sourceObject.getClass() == java.util.Date.class) {
date = (java.util.Date)sourceObject;//used when converting util.Date to Calendar
} else if (sourceObject instanceof java.sql.Date) {
date = Helper.utilDateFromSQLDate((java.sql.Date)sourceObject);
} else if (sourceObject instanceof java.sql.Time) {
date = Helper.utilDateFromTime((java.sql.Time)sourceObject);
} else if (sourceObject instanceof String) {
date = Helper.utilDateFromTimestamp(Helper.timestampFromString((String)sourceObject));
} else if (sourceObject instanceof java.sql.Timestamp) {
date = Helper.utilDateFromTimestamp((java.sql.Timestamp)sourceObject);
} else if (sourceObject instanceof Calendar) {
return ((Calendar)sourceObject).getTime();
} else if (sourceObject instanceof Long) {
date = Helper.utilDateFromLong((Long)sourceObject);
} else if (sourceObject instanceof java.util.Date) {
date = new java.util.Date(((java.util.Date) sourceObject).getTime());
} else {
throw ConversionException.couldNotBeConverted(sourceObject, ClassConstants.UTILDATE);
}
return date;
}
代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core
/**
* INTERNAL:
* Build a valid instance of java.util.Date from the given source object.
* @param sourceObject Valid instance of java.util.Date, String, java.sql.Timestamp, or Long
*/
protected java.util.Date convertObjectToUtilDate(Object sourceObject) throws ConversionException {
java.util.Date date = null;
if (sourceObject.getClass() == java.util.Date.class) {
date = (java.util.Date)sourceObject;//used when converting util.Date to Calendar
} else if (sourceObject instanceof java.sql.Date) {
date = Helper.utilDateFromSQLDate((java.sql.Date)sourceObject);
} else if (sourceObject instanceof java.sql.Time) {
date = Helper.utilDateFromTime((java.sql.Time)sourceObject);
} else if (sourceObject instanceof String) {
date = Helper.utilDateFromTimestamp(Helper.timestampFromString((String)sourceObject));
} else if (sourceObject instanceof java.sql.Timestamp) {
date = Helper.utilDateFromTimestamp((java.sql.Timestamp)sourceObject);
} else if (sourceObject instanceof Calendar) {
return ((Calendar)sourceObject).getTime();
} else if (sourceObject instanceof Long) {
date = Helper.utilDateFromLong((Long)sourceObject);
} else if (sourceObject instanceof java.util.Date) {
date = new java.util.Date(((java.util.Date) sourceObject).getTime());
} else {
throw ConversionException.couldNotBeConverted(sourceObject, ClassConstants.UTILDATE);
}
return date;
}
代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence
/**
* INTERNAL:
* Build a valid instance of java.util.Date from the given source object.
* @param sourceObject Valid instance of java.util.Date, String, java.sql.Timestamp, or Long
*/
protected java.util.Date convertObjectToUtilDate(Object sourceObject) throws ConversionException {
java.util.Date date = null;
if (sourceObject.getClass() == java.util.Date.class) {
date = (java.util.Date)sourceObject;//used when converting util.Date to Calendar
} else if (sourceObject instanceof java.sql.Date) {
date = Helper.utilDateFromSQLDate((java.sql.Date)sourceObject);
} else if (sourceObject instanceof java.sql.Time) {
date = Helper.utilDateFromTime((java.sql.Time)sourceObject);
} else if (sourceObject instanceof String) {
date = Helper.utilDateFromTimestamp(Helper.timestampFromString((String)sourceObject));
} else if (sourceObject instanceof java.sql.Timestamp) {
date = Helper.utilDateFromTimestamp((java.sql.Timestamp)sourceObject);
} else if (sourceObject instanceof Calendar) {
return ((Calendar)sourceObject).getTime();
} else if (sourceObject instanceof Long) {
date = Helper.utilDateFromLong((Long)sourceObject);
} else {
throw ConversionException.couldNotBeConverted(sourceObject, ClassConstants.UTILDATE);
}
return date;
}
代码示例来源:origin: com.haulmont.thirdparty/eclipselink
/**
* INTERNAL:
* Build a valid instance of java.sql.Timestamp from the given source object.
* @param sourceObject Valid obejct of class java.sql.Timestamp, String, java.util.Date, or Long
*/
protected java.sql.Timestamp convertObjectToTimestamp(Object sourceObject) throws ConversionException {
java.sql.Timestamp timestamp = null;
if (sourceObject instanceof java.sql.Timestamp) {
return (java.sql.Timestamp)sourceObject;// Helper timestamp is not caught on class check.
}
if (sourceObject instanceof String) {
timestamp = Helper.timestampFromString((String)sourceObject);
} else if (sourceObject instanceof java.util.Date) {// This handles all date and subclasses, sql.Date, sql.Time conversions.
timestamp = Helper.timestampFromDate((java.util.Date)sourceObject);
} else if (sourceObject instanceof Calendar) {
return Helper.timestampFromCalendar((Calendar)sourceObject);
} else if (sourceObject instanceof Long) {
timestamp = Helper.timestampFromLong((Long)sourceObject);
} else {
throw ConversionException.couldNotBeConverted(sourceObject, ClassConstants.TIMESTAMP);
}
return timestamp;
}
代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence
/**
* INTERNAL:
* Build a valid instance of java.sql.Timestamp from the given source object.
* @param sourceObject Valid obejct of class java.sql.Timestamp, String, java.util.Date, or Long
*/
protected java.sql.Timestamp convertObjectToTimestamp(Object sourceObject) throws ConversionException {
java.sql.Timestamp timestamp = null;
if (sourceObject instanceof java.sql.Timestamp) {
return (java.sql.Timestamp)sourceObject;// Helper timestamp is not caught on class check.
}
if (sourceObject instanceof String) {
timestamp = Helper.timestampFromString((String)sourceObject);
} else if (sourceObject instanceof java.util.Date) {// This handles all date and subclasses, sql.Date, sql.Time conversions.
timestamp = Helper.timestampFromDate((java.util.Date)sourceObject);
} else if (sourceObject instanceof Calendar) {
return Helper.timestampFromCalendar((Calendar)sourceObject);
} else if (sourceObject instanceof Long) {
timestamp = Helper.timestampFromLong((Long)sourceObject);
} else {
throw ConversionException.couldNotBeConverted(sourceObject, ClassConstants.TIMESTAMP);
}
return timestamp;
}
代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core
/**
* INTERNAL:
* Build a valid instance of java.sql.Timestamp from the given source object.
* @param sourceObject Valid object of class java.sql.Timestamp, String, java.util.Date, or Long
*/
protected java.sql.Timestamp convertObjectToTimestamp(Object sourceObject) throws ConversionException {
java.sql.Timestamp timestamp = null;
if (sourceObject instanceof java.sql.Timestamp) {
return (java.sql.Timestamp)sourceObject;// Helper timestamp is not caught on class check.
}
if (sourceObject instanceof String) {
timestamp = Helper.timestampFromString((String)sourceObject);
} else if (sourceObject instanceof java.util.Date) {// This handles all date and subclasses, sql.Date, sql.Time conversions.
timestamp = Helper.timestampFromDate((java.util.Date)sourceObject);
} else if (sourceObject instanceof Calendar) {
return Helper.timestampFromCalendar((Calendar)sourceObject);
} else if (sourceObject instanceof Long) {
timestamp = Helper.timestampFromLong((Long)sourceObject);
} else {
throw ConversionException.couldNotBeConverted(sourceObject, ClassConstants.TIMESTAMP);
}
return timestamp;
}
内容来源于网络,如有侵权,请联系作者删除!