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


Java DateTools.timeToString方法代码示例

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


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

示例1: uid

import org.apache.lucene.document.DateTools; //导入方法依赖的package包/类
public static String uid(File f) {
	// Append path and date into a string in such a way that lexicographic
	// sorting gives the same results as a walk of the file hierarchy. Thus
	// null (\u0000) is used both to separate directory components and to
	// separate the path from the date.
	return f.getPath().replace(dirSep, '\u0000') + "\u0000"
			+ DateTools.timeToString(f.lastModified(), DateTools.Resolution.SECOND);
}
 
开发者ID:kuzavas,项目名称:ephesoft,代码行数:9,代码来源:HTMLDocument.java

示例2: Document

import org.apache.lucene.document.DateTools; //导入方法依赖的package包/类
/**
 * Makes a document for a File.
 * <p>
 * The document has three fields:
 * <ul>
 * <li><code>path</code> containing the pathname of the file, as a
 * stored, tokenized field;
 * <li><code>modified</code> containing the last modified date of the
 * file as a keyword field as encoded by <a
 * href="lucene.document.DateField.html">DateField</a>; and
 * <li><code>contents</code> containing the full contents of the file, as
 * a Reader field;
 * </ul>
 */
public static Document Document(
               File f, 
               String notebookLabel,
               String conceptLabel,
               String conceptUri) throws java.io.FileNotFoundException {

	// make a new, empty lucene document
	Document doc = new Document();

       // no assemble the document from fields - some of them will be searchable,
       // others will be available in the result (as document attributes) i.e. stored in the index
       Field field;

       // concept URI as attribute - used to delete the document
       field = new Field("uri", conceptUri, Field.Store.YES, Field.Index.UN_TOKENIZED);
       doc.add(field);
       // path as attribute
       field = new Field("path", f.getPath(), Field.Store.YES, Field.Index.NO);
       doc.add(field);
       // SEARCHABLE concept label 
       field = new Field("conceptLabel", conceptLabel, Field.Store.YES, Field.Index.TOKENIZED);
       doc.add(field);
       // notebook label attribute 
       field = new Field("outlineLabel",notebookLabel,Field.Store.YES, Field.Index.NO);
       doc.add(field);
       // timestamp as attribute
       field = new Field("modified",DateTools.timeToString(f.lastModified(), DateTools.Resolution.SECOND),Field.Store.YES, Field.Index.NO);
       doc.add(field);

       // concept annotation - the most important
	FileInputStream is = new FileInputStream(f);
	Reader reader = new BufferedReader(new InputStreamReader(is));
       field = new Field("contents", reader);
       doc.add(field);

	// return the document
	return doc;
}
 
开发者ID:dvorka,项目名称:mindraider,代码行数:53,代码来源:FileDocument.java

示例3: createDocument

import org.apache.lucene.document.DateTools; //导入方法依赖的package包/类
private Document createDocument(String text, long time) {
  Document document = new Document();

  // Add the text field.
  Field textField = newTextField(TEXT_FIELD, text, Field.Store.YES);
  document.add(textField);

  // Add the date/time field.
  String dateTimeString = DateTools.timeToString(time, DateTools.Resolution.SECOND);
  Field dateTimeField = newStringField(DATE_TIME_FIELD, dateTimeString, Field.Store.YES);
  document.add(dateTimeField);

  return document;
}
 
开发者ID:europeana,项目名称:search,代码行数:15,代码来源:TestDateSort.java

示例4: timestampToIndexableString

import org.apache.lucene.document.DateTools; //导入方法依赖的package包/类
/**
 * Converts a time stamp to a String that can be indexed for search.
 * @param value the times stamp to convert
 * @return the indexable string
 */
protected static String timestampToIndexableString(Timestamp value) {
  if (value == null) {
    return null;
  } else {
    return DateTools.timeToString(value.getTime(),DateTools.Resolution.MILLISECOND);
  }
}
 
开发者ID:GeoinformationSystems,项目名称:GeoprocessingAppstore,代码行数:13,代码来源:TimestampField.java

示例5: getLuceneDate

import org.apache.lucene.document.DateTools; //导入方法依赖的package包/类
private String getLuceneDate() {
  return DateTools.timeToString(base.getTimeInMillis() + random.nextInt()
      - Integer.MIN_VALUE, DateTools.Resolution.DAY);
}
 
开发者ID:europeana,项目名称:search,代码行数:5,代码来源:TestCustomSearcherSort.java

示例6: appendWritableFields

import org.apache.lucene.document.DateTools; //导入方法依赖的package包/类
/**
 * Appends fields to a document for indexing.
 * @param document the document
 */
public void appendWritableFields(Document document) {
  Field fld;
  String val;
  long millis;
  
  // sys.assertionid
  val = Val.chkStr(this.getAssertionId());
  if (val.length() == 0) {
    this.setAssertionId(UUID.randomUUID().toString());
    val = Val.chkStr(this.getAssertionId());
  }
  fld = new Field(AsnConstants.FIELD_SYS_ASSERTIONID,val,
      Field.Store.YES,Field.Index.NOT_ANALYZED,Field.TermVector.NO);
  document.add(fld);
  
  // sys.edit.timestamp
  if (this.getEditTimestamp() != null) {
    millis = this.getEditTimestamp().getTime();
    val = DateTools.timeToString(millis,DateTools.Resolution.MILLISECOND);
    fld = new Field(AsnConstants.FIELD_SYS_EDIT_TIMESTAMP,val,
        Field.Store.YES,Field.Index.NOT_ANALYZED,Field.TermVector.NO);
    document.add(fld);
  }
  
  // sys.enabled
  if (!this.getEnabled()) {
    fld = new Field(AsnConstants.FIELD_SYS_ENABLED,"false",
        Field.Store.YES,Field.Index.NOT_ANALYZED,Field.TermVector.NO);
    document.add(fld);
  }
  
  // sys.resourceid
  val = Val.chkStr(this.getResourceId());
  if (val.length() > 0) {
    fld = new Field(AsnConstants.FIELD_SYS_RESOURCEID,val,
        Field.Store.YES,Field.Index.NOT_ANALYZED,Field.TermVector.NO);
    document.add(fld);
  }
  
  // sys.timestamp
  if (this.getTimestamp() == null) {
    this.setTimestamp(new Timestamp(System.currentTimeMillis()));
  }
  millis = this.getTimestamp().getTime();
  val = DateTools.timeToString(millis,DateTools.Resolution.MILLISECOND);
  fld = new Field(AsnConstants.FIELD_SYS_TIMESTAMP,val,
      Field.Store.YES,Field.Index.NOT_ANALYZED,Field.TermVector.NO);
  document.add(fld);
  
}
 
开发者ID:GeoinformationSystems,项目名称:GeoprocessingAppstore,代码行数:55,代码来源:AsnSystemPart.java

示例7: timeToString

import org.apache.lucene.document.DateTools; //导入方法依赖的package包/类
/**
 *  Converts a millisecond time to a string suitable for indexing using resolution to seconds.
 *
 * @param  time  Time in millisonds
 * @return       A string in format yyyyMMddHHmmss; using UTC as timezone
 */
public final static String timeToString(long time) {
	return DateTools.timeToString(time, DateTools.Resolution.SECOND);
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:10,代码来源:DateFieldTools.java


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