当前位置: 首页>>代码示例>>Java>>正文


Java DateTools.stringToTime方法代码示例

本文整理汇总了Java中org.apache.lucene.document.DateTools.stringToTime方法的典型用法代码示例。如果您正苦于以下问题:Java DateTools.stringToTime方法的具体用法?Java DateTools.stringToTime怎么用?Java DateTools.stringToTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.lucene.document.DateTools的用法示例。


在下文中一共展示了DateTools.stringToTime方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: stringToTime

import org.apache.lucene.document.DateTools; //导入方法依赖的package包/类
/**
 *  Converts a string produced by {@link #timeToString} or {@link #dateToString} back to a time, represented
 *  as the number of milliseconds since January 1, 1970, 00:00:00 GMT. Is also able to parse dates encoded in
 *  the old Lucene 1.x DateField format, for compatibility with old indexes (this functionality will go away
 *  in a future release).
 *
 * @param  dateString          A string produced by timeToString or dateToString
 * @return                     The number of milliseconds since January 1, 1970, 00:00:00 GMT
 * @exception  ParseException  If parse error
 */
public final static long stringToTime(String dateString) throws ParseException {
	try {
		return DateTools.stringToTime(dateString);
	} catch (ParseException pe) {
		// Handle dates encoded in the Lucene 1.x format, for compatibility with old indexes
		try {
			// This method will go away in a future release of Lucene...
			return DateField.stringToTime(dateString);
		} catch (Throwable t) {
			throw new ParseException("Unable to parse date string: " + t.getMessage(), 0);
		}
	}
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:24,代码来源:DateFieldTools.java

示例2: getModfiedDate

import org.apache.lucene.document.DateTools; //导入方法依赖的package包/类
@Override
public Date getModfiedDate() {
  try {
    return new Date(DateTools.stringToTime(select(PropertyMeanings.NAME_DATEMODIFIED)));
  } catch (ParseException ex) {
    return new Date();
  }
}
 
开发者ID:GeoinformationSystems,项目名称:GeoprocessingAppstore,代码行数:9,代码来源:DiscoveredRecordAdapter.java

示例3: timestampFromIndexableString

import org.apache.lucene.document.DateTools; //导入方法依赖的package包/类
/**
 * Reverts an indexable String back to a time stamp.
 * @param value the indexable string to revert
 * @return the update date (null if the value is invalid)
 */
protected static Timestamp timestampFromIndexableString(String value) {
  try {
    long lValue = DateTools.stringToTime(value);
    return new Timestamp(lValue);
  } catch (ParseException e) {
    return null;
  }
}
 
开发者ID:GeoinformationSystems,项目名称:GeoprocessingAppstore,代码行数:14,代码来源:TimestampField.java

示例4: isFullDate

import org.apache.lucene.document.DateTools; //导入方法依赖的package包/类
/**
 * Checks if provided date is a full date stored in the index. Full date is
 * a date of milliseconds resolution.
 * @param queryText possibly a full date
 * @return <code>true</code> if this is a full date.
 */
private boolean isFullDate(String queryText) {
  try {
    queryText = Val.chkStr(queryText);
    long lngDate = DateTools.stringToTime(queryText);
    return queryText.matches("[0-9]+") && queryText.length() >= DateTools.timeToString(lngDate, DateTools.Resolution.MILLISECOND).length();
  } catch (java.text.ParseException ex) {
    return false;
  }
}
 
开发者ID:GeoinformationSystems,项目名称:GeoprocessingAppstore,代码行数:16,代码来源:QueryProvider.java


注:本文中的org.apache.lucene.document.DateTools.stringToTime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。