當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。