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

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

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

Helper.timeFromString介绍

[英]Answer a Time from a string representation. This method will accept times in the following formats: HH-MM-SS, HH:MM:SS
[中]用字符串表示法回答时间。此方法将接受以下格式的时间:HH-MM-SS,HH:MM:SS

代码示例

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

/**
 * INTERNAL:
 * Build a valid instance of java.sql.Time from the given source object.
 * @param    sourceObject    Valid instance of java.sql.Time, String, java.util.Date, java.sql.Timestamp, or Long
 */
protected java.sql.Time convertObjectToTime(Object sourceObject) throws ConversionException {
  java.sql.Time time = null;
  if (sourceObject instanceof java.sql.Time) {
    return (java.sql.Time)sourceObject;//Helper timestamp is not caught on class check.
  }
  if (sourceObject instanceof String) {
    time = Helper.timeFromString((String)sourceObject);
  } else if (sourceObject.getClass() == ClassConstants.UTILDATE) {
    time = Helper.timeFromDate((java.util.Date)sourceObject);
  } else if (sourceObject instanceof java.sql.Timestamp) {
    time = Helper.timeFromTimestamp((java.sql.Timestamp)sourceObject);
  } else if (sourceObject instanceof Calendar) {
    return Helper.timeFromCalendar((Calendar)sourceObject);
  } else if (sourceObject instanceof Long) {
    time = Helper.timeFromLong((Long)sourceObject);
  } else if (sourceObject.getClass() == ClassConstants.TIME_LTIME) {
    time = java.sql.Time.valueOf((java.time.LocalTime) sourceObject);
  } else if (sourceObject.getClass() == ClassConstants.TIME_OTIME) {
    time = java.sql.Time.valueOf(((java.time.OffsetTime) sourceObject).toLocalTime());
  } else {
    throw ConversionException.couldNotBeConverted(sourceObject, ClassConstants.TIME);
  }
  return time;
}

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

DatabaseQuery applyToDatabaseQuery(Object valueToApply, DatabaseQuery query, ClassLoader loader, AbstractSession activeSession) {
    if (query.isReadQuery()) {
      ReadQuery readQuery = (ReadQuery)query;
      if (readQuery.getQueryResultsCachePolicy() == null) {
        readQuery.cacheQueryResults();
      }
      try {
        Time time = Helper.timeFromString((String)valueToApply);
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(time);
        readQuery.getQueryResultsCachePolicy().setCacheInvalidationPolicy(
            new DailyCacheInvalidationPolicy(calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), calendar.get(Calendar.SECOND), 0));
      } catch (ConversionException exception) {
        throw QueryException.queryHintContainedInvalidIntegerValue(QueryHints.QUERY_RESULTS_CACHE_EXPIRY_TIME_OF_DAY, valueToApply, exception);
      }
    } 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.sql.Time from the given source object.
 * @param    sourceObject    Valid instance of java.sql.Time, String, java.util.Date, java.sql.Timestamp, or Long
 */
protected java.sql.Time convertObjectToTime(Object sourceObject) throws ConversionException {
  java.sql.Time time = null;
  if (sourceObject instanceof java.sql.Time) {
    return (java.sql.Time)sourceObject;//Helper timestamp is not caught on class check.
  }
  if (sourceObject instanceof String) {
    time = Helper.timeFromString((String)sourceObject);
  } else if (sourceObject.getClass() == ClassConstants.UTILDATE) {
    time = Helper.timeFromDate((java.util.Date)sourceObject);
  } else if (sourceObject instanceof java.sql.Timestamp) {
    time = Helper.timeFromTimestamp((java.sql.Timestamp)sourceObject);
  } else if (sourceObject instanceof Calendar) {
    return Helper.timeFromCalendar((Calendar)sourceObject);
  } else if (sourceObject instanceof Long) {
    time = Helper.timeFromLong((Long)sourceObject);
  } else {
    throw ConversionException.couldNotBeConverted(sourceObject, ClassConstants.TIME);
  }
  return time;
}

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

/**
 * INTERNAL:
 * Build a valid instance of java.sql.Time from the given source object.
 * @param    sourceObject    Valid instance of java.sql.Time, String, java.util.Date, java.sql.Timestamp, or Long
 */
protected java.sql.Time convertObjectToTime(Object sourceObject) throws ConversionException {
  java.sql.Time time = null;
  if (sourceObject instanceof java.sql.Time) {
    return (java.sql.Time)sourceObject;//Helper timestamp is not caught on class check.
  }
  if (sourceObject instanceof String) {
    time = Helper.timeFromString((String)sourceObject);
  } else if (sourceObject.getClass() == ClassConstants.UTILDATE) {
    time = Helper.timeFromDate((java.util.Date)sourceObject);
  } else if (sourceObject instanceof java.sql.Timestamp) {
    time = Helper.timeFromTimestamp((java.sql.Timestamp)sourceObject);
  } else if (sourceObject instanceof Calendar) {
    return Helper.timeFromCalendar((Calendar)sourceObject);
  } else if (sourceObject instanceof Long) {
    time = Helper.timeFromLong((Long)sourceObject);
  } else {
    throw ConversionException.couldNotBeConverted(sourceObject, ClassConstants.TIME);
  }
  return time;
}

相关文章

Helper类方法