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

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

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

Helper.dateFromString介绍

[英]Answer a Date from a string representation. The string MUST be a valid date and in one of the following formats: YYYY/MM/DD, YYYY-MM-DD, YY/MM/DD, YY-MM-DD. This implementation is based on the java.sql.Date class, not java.util.Date. The Date class contains some minor gotchas that you have to watch out for.
[中]从字符串表示中回答日期。字符串必须是有效的日期,并采用以下格式之一:YYYY/MM/DD、YYYY-MM-DD、YY/MM/DD、YY-MM-DD。此实现基于java。sql。日期类,而不是java。util。日期Date类包含一些您必须注意的小问题。

代码示例

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

/**
 * Convert the object to an instance of java.sql.Date.
 *    @param    sourceObject Object of type java.sql.Timestamp, java.util.Date, String or Long
 */
protected java.sql.Date convertObjectToDate(Object sourceObject) throws ConversionException {
  java.sql.Date date = null;
  if (sourceObject instanceof java.sql.Date) {
    date = (java.sql.Date)sourceObject;//Helper date is not caught on class check.
  } else if (sourceObject instanceof java.sql.Timestamp) {
    date = Helper.dateFromTimestamp((java.sql.Timestamp)sourceObject);
  } else if (sourceObject.getClass() == ClassConstants.UTILDATE) {
    date = Helper.sqlDateFromUtilDate((java.util.Date)sourceObject);
  } else if (sourceObject instanceof Calendar) {
    return Helper.dateFromCalendar((Calendar)sourceObject);
  } else if (sourceObject instanceof String) {
    date = Helper.dateFromString((String)sourceObject);
  } else if (sourceObject instanceof Long) {
    date = Helper.dateFromLong((Long)sourceObject);
  } else {
    throw ConversionException.couldNotBeConverted(sourceObject, ClassConstants.SQLDATE);
  }
  return date;
}

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

/**
 * Convert the object to an instance of java.sql.Date.
 *    @param    sourceObject Object of type java.sql.Timestamp, java.util.Date, String or Long
 */
protected java.sql.Date convertObjectToDate(Object sourceObject) throws ConversionException {
  java.sql.Date date = null;
  if (sourceObject instanceof java.sql.Date) {
    date = (java.sql.Date)sourceObject;//Helper date is not caught on class check.
  } else if (sourceObject instanceof java.sql.Timestamp) {
    date = Helper.dateFromTimestamp((java.sql.Timestamp)sourceObject);
  } else if (sourceObject.getClass() == ClassConstants.UTILDATE) {
    date = Helper.sqlDateFromUtilDate((java.util.Date)sourceObject);
  } else if (sourceObject instanceof Calendar) {
    return Helper.dateFromCalendar((Calendar)sourceObject);
  } else if (sourceObject instanceof String) {
    date = Helper.dateFromString((String)sourceObject);
  } else if (sourceObject instanceof Long) {
    date = Helper.dateFromLong((Long)sourceObject);
  } else {
    throw ConversionException.couldNotBeConverted(sourceObject, ClassConstants.SQLDATE);
  }
  return date;
}

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

/**
 * Convert the object to an instance of java.sql.Date.
 *    @param    sourceObject Object of type java.sql.Timestamp, java.util.Date, String or Long
 */
protected java.sql.Date convertObjectToDate(Object sourceObject) throws ConversionException {
  java.sql.Date date = null;
  if (sourceObject instanceof java.sql.Date) {
    date = (java.sql.Date)sourceObject;//Helper date is not caught on class check.
  } else if (sourceObject instanceof java.sql.Timestamp) {
    date = Helper.dateFromTimestamp((java.sql.Timestamp)sourceObject);
  } else if (sourceObject.getClass() == ClassConstants.UTILDATE) {
    date = Helper.sqlDateFromUtilDate((java.util.Date)sourceObject);
  } else if (sourceObject instanceof Calendar) {
    return Helper.dateFromCalendar((Calendar)sourceObject);
  } else if (sourceObject instanceof String) {
    date = Helper.dateFromString((String)sourceObject);
  } else if (sourceObject instanceof Long) {
    date = Helper.dateFromLong((Long)sourceObject);
  } else {
    throw ConversionException.couldNotBeConverted(sourceObject, ClassConstants.SQLDATE);
  }
  return date;
}

相关文章

Helper类方法