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

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

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

Helper.timestampFromDate介绍

[英]Answer a Timestamp from a java.util.Date.
[中]回答来自java的时间戳。util。日期

代码示例

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

/**
 * INTERNAL
 * We support more primitive than JDBC does so we must do conversion before printing or binding.
 */
public Object convertToDatabaseType(Object value) {
  if (value == null) {
    return null;
  }
  if (value.getClass() == ClassConstants.UTILDATE) {
    return Helper.timestampFromDate((java.util.Date)value);
  } else if (value instanceof Character) {
    return ((Character)value).toString();
  } else if (value instanceof Calendar) {
    return Helper.timestampFromDate(((Calendar)value).getTime());
  } else if (value instanceof BigInteger) {
    return new BigDecimal((BigInteger)value);
  } else if (value instanceof char[]) {
    return new String((char[])value);
  } else if (value instanceof Character[]) {
    return convertObject(value, ClassConstants.STRING);
  } else if (value instanceof Byte[]) {
    return convertObject(value, ClassConstants.APBYTE);
  }
  return value;
}

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

/**
 * INTERNAL
 * We support more primitive than JDBC does so we must do conversion before printing or binding.
 */
public Object convertToDatabaseType(Object value) {
  if (value == null) {
    return null;
  }
  if (value.getClass() == ClassConstants.UTILDATE) {
    return Helper.timestampFromDate((java.util.Date)value);
  } else if (value instanceof Character) {
    return ((Character)value).toString();
  } else if (value instanceof Calendar) {
    return Helper.timestampFromDate(((Calendar)value).getTime());
  } else if (value instanceof BigInteger) {
    return new BigDecimal((BigInteger)value);
  } else if (value instanceof char[]) {
    return new String((char[])value);
  } else if (value instanceof Character[]) {
    return convertObject(value, ClassConstants.STRING);
  } else if (value instanceof Byte[]) {
    return convertObject(value, ClassConstants.APBYTE);
  }
  return value;
}

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

/**
 * INTERNAL
 * We support more primitive than JDBC does so we must do conversion before printing or binding.
 */
public Object convertToDatabaseType(Object value) {
  if (value == null) {
    return null;
  }
  if (value.getClass() == ClassConstants.UTILDATE) {
    return Helper.timestampFromDate((java.util.Date)value);
  } else if (value instanceof Character) {
    return ((Character)value).toString();
  } else if (value instanceof Calendar) {
    return Helper.timestampFromDate(((Calendar)value).getTime());
  } else if (value instanceof BigInteger) {
    return new BigDecimal((BigInteger)value);
  } else if (value instanceof char[]) {
    return new String((char[])value);
  } else if (value instanceof Character[]) {
    return convertObject(value, ClassConstants.STRING);
  } else if (value instanceof Byte[]) {
    return convertObject(value, ClassConstants.APBYTE);
  }
  return value;
}

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

statement.setTimestamp(index, Helper.timestampFromDate(((Calendar)parameter).getTime()));
} else if (parameter.getClass() == ClassConstants.UTILDATE) {
  statement.setTimestamp(index, Helper.timestampFromDate((java.util.Date) parameter));
} else if (parameter instanceof Character) {
  statement.setString(index, ((Character)parameter).toString());

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

statement.setTimestamp(index, Helper.timestampFromDate(((Calendar)parameter).getTime()));
} else if (parameter.getClass() == ClassConstants.UTILDATE) {
  statement.setTimestamp(index, Helper.timestampFromDate((java.util.Date) parameter));
} else if (parameter instanceof Character) {
  statement.setString(index, ((Character)parameter).toString());

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

return sourceObject.toString();
} else if (sourceObjectClass == ClassConstants.UTILDATE) {
  return Helper.printTimestamp(Helper.timestampFromDate((java.util.Date)sourceObject));
} else if (sourceObject instanceof java.util.Calendar) {
  return Helper.printCalendar((Calendar)sourceObject);

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

statement.setTimestamp(index, Helper.timestampFromDate(((Calendar)parameter).getTime()));
} else if (parameter.getClass() == ClassConstants.UTILDATE) {
  statement.setTimestamp(index, Helper.timestampFromDate((java.util.Date) parameter));
} else if (parameter instanceof Character) {
  statement.setString(index, ((Character)parameter).toString());

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

return sourceObject.toString();
} else if (sourceObjectClass == ClassConstants.UTILDATE) {
  return Helper.printTimestamp(Helper.timestampFromDate((java.util.Date)sourceObject));
} else if (sourceObject instanceof java.util.Calendar) {
  return Helper.printCalendar((Calendar)sourceObject);

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

return Helper.printTimestamp(Helper.timestampFromDate((java.util.Date)sourceObject));
} else if (sourceObject instanceof Calendar) {
  return Helper.printCalendar((Calendar)sourceObject);

代码示例来源: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/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;
}

代码示例来源: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;
}

相关文章

Helper类方法