本文整理汇总了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;
}
}