KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > japex > report > ReportFilter


1 /*
2  * ReportFilter.java
3  *
4  * Created on April 6, 2005, 6:07 PM
5  */

6
7 package com.sun.japex.report;
8
9 import java.io.File JavaDoc;
10 import java.io.FileFilter JavaDoc;
11 import java.util.Date JavaDoc;
12 import java.text.DateFormat JavaDoc;
13 import java.text.ParseException JavaDoc;
14 import java.text.SimpleDateFormat JavaDoc;
15
16
17 public class ReportFilter implements FileFilter JavaDoc {
18     Date JavaDoc _from;
19     Date JavaDoc _to;
20     
21     public ReportFilter(Date JavaDoc from, Date JavaDoc to) {
22         _from = from;
23         _to = to;
24 //System.out.println("from:" + _from);
25
//System.out.println("to:" + _to);
26
}
27     /*
28     public ReportFilter(String from, String to) {
29         try {
30             DateFormat df= new SimpleDateFormat ("yyyy-MM-dd");
31             _from = df.parse(from);
32             _to = df.parse(to);
33         } catch (ParseException pe) {
34             System.out.println(pe.getMessage());
35         }
36     }
37       
38      */

39     public boolean accept(File JavaDoc pathname) {
40         if (pathname.isDirectory()) {
41             long date = pathname.lastModified();
42             if (date >= _from.getTime() && date <= _to.getTime()) {
43 //System.out.println("Filterd: "+new Date(pathname.lastModified()));
44
return true;
45             }
46         }
47         return false;
48     }
49     
50 }
51
Popular Tags