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


Java DateTools.stringToDate方法代码示例

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


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

示例1: createSearchResult

import org.apache.lucene.document.DateTools; //导入方法依赖的package包/类
private SearchResult createSearchResult(Document doc, float score, int hitId, int totalHits) throws ParseException {
	SearchResult result = new SearchResult();
	result.hitId = hitId;
	result.totalHits = totalHits;
	result.score = score;
	result.date = DateTools.stringToDate(doc.get(FIELD_DATE));
	result.summary = doc.get(FIELD_SUMMARY);
	result.author = doc.get(FIELD_AUTHOR);
	result.committer = doc.get(FIELD_COMMITTER);
	result.type = SearchObjectType.fromName(doc.get(FIELD_OBJECT_TYPE));
	result.branch = doc.get(FIELD_BRANCH);
	result.commitId = doc.get(FIELD_COMMIT);
	result.path = doc.get(FIELD_PATH);
	if (doc.get(FIELD_TAG) != null) {
		result.tags = StringUtils.getStringsFromValue(doc.get(FIELD_TAG));
	}
	return result;
}
 
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:19,代码来源:LuceneService.java

示例2: stringToDate

import org.apache.lucene.document.DateTools; //导入方法依赖的package包/类
/**
 *  Converts a string produced by {@link #timeToString} or {@link #dateToString} back to a time, represented
 *  as a Date object. 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 parsed time as a Date object
 * @exception  ParseException  If parse error
 */
public final static Date stringToDate(String dateString) throws ParseException {
	try {
		return DateTools.stringToDate(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.stringToDate(dateString);
		} catch (Throwable t) {
			throw new ParseException("Unable to parse date string: " + t.getMessage(), 0);
		}
	}
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:23,代码来源:DateFieldTools.java

示例3: assertDocData

import org.apache.lucene.document.DateTools; //导入方法依赖的package包/类
private void assertDocData(DocData dd, String expName, String expTitle,
                           String expBody, Date expDate)
    throws ParseException {
  assertNotNull(dd);
  assertEquals(expName, dd.getName());
  assertEquals(expTitle, dd.getTitle());
  assertTrue(dd.getBody().indexOf(expBody) != -1);
  Date date = dd.getDate() != null ? DateTools.stringToDate(dd.getDate()) : null;
  assertEquals(expDate, date);
}
 
开发者ID:europeana,项目名称:search,代码行数:11,代码来源:TrecContentSourceTest.java

示例4: stringToObject

import org.apache.lucene.document.DateTools; //导入方法依赖的package包/类
public Object stringToObject(String stringValue) {
    if ( StringHelper.isEmpty( stringValue ) ) return null;
    try {
        return DateTools.stringToDate( stringValue );
    }
    catch (ParseException e) {
        throw new SearchException( "Unable to parse into date: " + stringValue, e );
    }
}
 
开发者ID:webdsl,项目名称:webdsl,代码行数:10,代码来源:WebDSLDateBridge.java


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