本文整理匯總了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);
}
}
}
示例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();
}
}
示例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;
}
}
示例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;
}
}