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