From d3134cf17144212d47741b64ef01952ea0297c7e Mon Sep 17 00:00:00 2001 From: Daniel Naber Date: Sun, 5 Sep 2004 21:47:57 +0000 Subject: [PATCH] use the new DateTools class to limit the date resolution and save the date in a readable format git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@150485 13f79535-47bb-0310-9956-ffa450edef68 --- src/demo/org/apache/lucene/demo/FileDocument.java | 9 +++++---- src/demo/org/apache/lucene/demo/HTMLDocument.java | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/demo/org/apache/lucene/demo/FileDocument.java b/src/demo/org/apache/lucene/demo/FileDocument.java index 2d68e3ef114..69f1b7ef7cf 100644 --- a/src/demo/org/apache/lucene/demo/FileDocument.java +++ b/src/demo/org/apache/lucene/demo/FileDocument.java @@ -19,9 +19,9 @@ package org.apache.lucene.demo; import java.io.File; import java.io.FileReader; +import org.apache.lucene.document.DateTools; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; -import org.apache.lucene.document.DateField; /** A utility for making Lucene Documents from a File. */ @@ -33,8 +33,8 @@ public class FileDocument {
  • path--containing the pathname of the file, as a stored, untokenized field;
  • modified--containing the last modified date of the file as - a keyword field as encoded by DateField; and + a field as created by DateTools; and
  • contents--containing the full contents of the file, as a Reader field; */ @@ -51,7 +51,8 @@ public class FileDocument { // Add the last modified date of the file a field named "modified". Use // a field that is indexed (i.e. searchable), but don't tokenize the field // into words. - doc.add(new Field("modified", DateField.timeToString(f.lastModified()), + doc.add(new Field("modified", + DateTools.timeToString(f.lastModified(), DateTools.Resolution.MINUTE), Field.Store.YES, Field.Index.UN_TOKENIZED)); // Add the contents of the file to a field named "contents". Specify a Reader, diff --git a/src/demo/org/apache/lucene/demo/HTMLDocument.java b/src/demo/org/apache/lucene/demo/HTMLDocument.java index 663b8dea564..72ee49778ee 100644 --- a/src/demo/org/apache/lucene/demo/HTMLDocument.java +++ b/src/demo/org/apache/lucene/demo/HTMLDocument.java @@ -53,7 +53,8 @@ public class HTMLDocument { // Add the last modified date of the file a field named "modified". // Use a field that is indexed (i.e. searchable), but don't tokenize // the field into words. - doc.add(new Field("modified", DateField.timeToString(f.lastModified()), + doc.add(new Field("modified", + DateTools.timeToString(f.lastModified(), DateTools.Resolution.MINUTE), Field.Store.YES, Field.Index.UN_TOKENIZED)); // Add the uid as a field, so that index can be incrementally maintained.