org.eclipse.persistence.internal.helper.Helper.timestampFromString()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(106)

本文整理了Java中org.eclipse.persistence.internal.helper.Helper.timestampFromString()方法的一些代码示例,展示了Helper.timestampFromString()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Helper.timestampFromString()方法的具体详情如下:
包路径:org.eclipse.persistence.internal.helper.Helper
类名称:Helper
方法名:timestampFromString

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

  1. DatabaseQuery applyToDatabaseQuery(Object valueToApply, DatabaseQuery query, ClassLoader loader, AbstractSession activeSession) {
  2. if (query.isObjectLevelReadQuery()) {
  3. ((ObjectLevelReadQuery) query).setAsOfClause(new AsOfClause(Helper.timestampFromString((String)valueToApply)));
  4. } else {
  5. throw new IllegalArgumentException(ExceptionLocalization.buildMessage("ejb30-wrong-type-for-query-hint",new Object[]{getQueryId(query), name, getPrintValue(valueToApply)}));
  6. }
  7. return query;
  8. }
  9. }

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

  1. /**
  2. * INTERNAL:
  3. * Build a valid instance of java.util.Date from the given source object.
  4. * @param sourceObject Valid instance of java.util.Date, String, java.sql.Timestamp, or Long
  5. */
  6. protected java.util.Date convertObjectToUtilDate(Object sourceObject) throws ConversionException {
  7. java.util.Date date = null;
  8. if (sourceObject.getClass() == java.util.Date.class) {
  9. date = (java.util.Date)sourceObject;//used when converting util.Date to Calendar
  10. } else if (sourceObject instanceof java.sql.Date) {
  11. date = Helper.utilDateFromSQLDate((java.sql.Date)sourceObject);
  12. } else if (sourceObject instanceof java.sql.Time) {
  13. date = Helper.utilDateFromTime((java.sql.Time)sourceObject);
  14. } else if (sourceObject instanceof String) {
  15. date = Helper.utilDateFromTimestamp(Helper.timestampFromString((String)sourceObject));
  16. } else if (sourceObject instanceof java.sql.Timestamp) {
  17. date = Helper.utilDateFromTimestamp((java.sql.Timestamp)sourceObject);
  18. } else if (sourceObject instanceof Calendar) {
  19. return ((Calendar)sourceObject).getTime();
  20. } else if (sourceObject instanceof Long) {
  21. date = Helper.utilDateFromLong((Long)sourceObject);
  22. } else if (sourceObject instanceof java.util.Date) {
  23. date = new java.util.Date(((java.util.Date) sourceObject).getTime());
  24. } else {
  25. throw ConversionException.couldNotBeConverted(sourceObject, ClassConstants.UTILDATE);
  26. }
  27. return date;
  28. }

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core

  1. /**
  2. * INTERNAL:
  3. * Build a valid instance of java.util.Date from the given source object.
  4. * @param sourceObject Valid instance of java.util.Date, String, java.sql.Timestamp, or Long
  5. */
  6. protected java.util.Date convertObjectToUtilDate(Object sourceObject) throws ConversionException {
  7. java.util.Date date = null;
  8. if (sourceObject.getClass() == java.util.Date.class) {
  9. date = (java.util.Date)sourceObject;//used when converting util.Date to Calendar
  10. } else if (sourceObject instanceof java.sql.Date) {
  11. date = Helper.utilDateFromSQLDate((java.sql.Date)sourceObject);
  12. } else if (sourceObject instanceof java.sql.Time) {
  13. date = Helper.utilDateFromTime((java.sql.Time)sourceObject);
  14. } else if (sourceObject instanceof String) {
  15. date = Helper.utilDateFromTimestamp(Helper.timestampFromString((String)sourceObject));
  16. } else if (sourceObject instanceof java.sql.Timestamp) {
  17. date = Helper.utilDateFromTimestamp((java.sql.Timestamp)sourceObject);
  18. } else if (sourceObject instanceof Calendar) {
  19. return ((Calendar)sourceObject).getTime();
  20. } else if (sourceObject instanceof Long) {
  21. date = Helper.utilDateFromLong((Long)sourceObject);
  22. } else if (sourceObject instanceof java.util.Date) {
  23. date = new java.util.Date(((java.util.Date) sourceObject).getTime());
  24. } else {
  25. throw ConversionException.couldNotBeConverted(sourceObject, ClassConstants.UTILDATE);
  26. }
  27. return date;
  28. }

代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

  1. /**
  2. * INTERNAL:
  3. * Build a valid instance of java.util.Date from the given source object.
  4. * @param sourceObject Valid instance of java.util.Date, String, java.sql.Timestamp, or Long
  5. */
  6. protected java.util.Date convertObjectToUtilDate(Object sourceObject) throws ConversionException {
  7. java.util.Date date = null;
  8. if (sourceObject.getClass() == java.util.Date.class) {
  9. date = (java.util.Date)sourceObject;//used when converting util.Date to Calendar
  10. } else if (sourceObject instanceof java.sql.Date) {
  11. date = Helper.utilDateFromSQLDate((java.sql.Date)sourceObject);
  12. } else if (sourceObject instanceof java.sql.Time) {
  13. date = Helper.utilDateFromTime((java.sql.Time)sourceObject);
  14. } else if (sourceObject instanceof String) {
  15. date = Helper.utilDateFromTimestamp(Helper.timestampFromString((String)sourceObject));
  16. } else if (sourceObject instanceof java.sql.Timestamp) {
  17. date = Helper.utilDateFromTimestamp((java.sql.Timestamp)sourceObject);
  18. } else if (sourceObject instanceof Calendar) {
  19. return ((Calendar)sourceObject).getTime();
  20. } else if (sourceObject instanceof Long) {
  21. date = Helper.utilDateFromLong((Long)sourceObject);
  22. } else {
  23. throw ConversionException.couldNotBeConverted(sourceObject, ClassConstants.UTILDATE);
  24. }
  25. return date;
  26. }

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

  1. /**
  2. * INTERNAL:
  3. * Build a valid instance of java.sql.Timestamp from the given source object.
  4. * @param sourceObject Valid obejct of class java.sql.Timestamp, String, java.util.Date, or Long
  5. */
  6. protected java.sql.Timestamp convertObjectToTimestamp(Object sourceObject) throws ConversionException {
  7. java.sql.Timestamp timestamp = null;
  8. if (sourceObject instanceof java.sql.Timestamp) {
  9. return (java.sql.Timestamp)sourceObject;// Helper timestamp is not caught on class check.
  10. }
  11. if (sourceObject instanceof String) {
  12. timestamp = Helper.timestampFromString((String)sourceObject);
  13. } else if (sourceObject instanceof java.util.Date) {// This handles all date and subclasses, sql.Date, sql.Time conversions.
  14. timestamp = Helper.timestampFromDate((java.util.Date)sourceObject);
  15. } else if (sourceObject instanceof Calendar) {
  16. return Helper.timestampFromCalendar((Calendar)sourceObject);
  17. } else if (sourceObject instanceof Long) {
  18. timestamp = Helper.timestampFromLong((Long)sourceObject);
  19. } else {
  20. throw ConversionException.couldNotBeConverted(sourceObject, ClassConstants.TIMESTAMP);
  21. }
  22. return timestamp;
  23. }

代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

  1. /**
  2. * INTERNAL:
  3. * Build a valid instance of java.sql.Timestamp from the given source object.
  4. * @param sourceObject Valid obejct of class java.sql.Timestamp, String, java.util.Date, or Long
  5. */
  6. protected java.sql.Timestamp convertObjectToTimestamp(Object sourceObject) throws ConversionException {
  7. java.sql.Timestamp timestamp = null;
  8. if (sourceObject instanceof java.sql.Timestamp) {
  9. return (java.sql.Timestamp)sourceObject;// Helper timestamp is not caught on class check.
  10. }
  11. if (sourceObject instanceof String) {
  12. timestamp = Helper.timestampFromString((String)sourceObject);
  13. } else if (sourceObject instanceof java.util.Date) {// This handles all date and subclasses, sql.Date, sql.Time conversions.
  14. timestamp = Helper.timestampFromDate((java.util.Date)sourceObject);
  15. } else if (sourceObject instanceof Calendar) {
  16. return Helper.timestampFromCalendar((Calendar)sourceObject);
  17. } else if (sourceObject instanceof Long) {
  18. timestamp = Helper.timestampFromLong((Long)sourceObject);
  19. } else {
  20. throw ConversionException.couldNotBeConverted(sourceObject, ClassConstants.TIMESTAMP);
  21. }
  22. return timestamp;
  23. }

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core

  1. /**
  2. * INTERNAL:
  3. * Build a valid instance of java.sql.Timestamp from the given source object.
  4. * @param sourceObject Valid object of class java.sql.Timestamp, String, java.util.Date, or Long
  5. */
  6. protected java.sql.Timestamp convertObjectToTimestamp(Object sourceObject) throws ConversionException {
  7. java.sql.Timestamp timestamp = null;
  8. if (sourceObject instanceof java.sql.Timestamp) {
  9. return (java.sql.Timestamp)sourceObject;// Helper timestamp is not caught on class check.
  10. }
  11. if (sourceObject instanceof String) {
  12. timestamp = Helper.timestampFromString((String)sourceObject);
  13. } else if (sourceObject instanceof java.util.Date) {// This handles all date and subclasses, sql.Date, sql.Time conversions.
  14. timestamp = Helper.timestampFromDate((java.util.Date)sourceObject);
  15. } else if (sourceObject instanceof Calendar) {
  16. return Helper.timestampFromCalendar((Calendar)sourceObject);
  17. } else if (sourceObject instanceof Long) {
  18. timestamp = Helper.timestampFromLong((Long)sourceObject);
  19. } else {
  20. throw ConversionException.couldNotBeConverted(sourceObject, ClassConstants.TIMESTAMP);
  21. }
  22. return timestamp;
  23. }

相关文章

Helper类方法