99import java .nio .file .Paths ;
1010
1111import java .nio .file .StandardCopyOption ;
12- import java .text .SimpleDateFormat ;
1312import java .time .LocalDate ;
1413import java .time .format .DateTimeFormatter ;
1514import java .time .format .DateTimeParseException ;
16- import java .util .ArrayList ;
17- import java .util .Collections ;
18- import java .util .List ;
15+ import java .time .format .FormatStyle ;
16+ import java .util .*;
1917
2018public class Scanning {
2119
@@ -39,8 +37,9 @@ public String getFileNamePartByWordLookupMatch(List<String> pdfWordList, List<Lo
3937
4038 public String getFileNamePartByDateLookup (String pdfText ) {
4139 try {
42- return getNewestDateFromString (pdfText );
40+ return getRelevantDateFromString (pdfText );
4341 } catch (Exception e ) {
42+ e .printStackTrace ();
4443 return "XXXX_XX_XX" ;
4544 }
4645 }
@@ -52,7 +51,7 @@ private static int countMatch(List<String> list1,List<String> list2) {
5251 return list1 .size ();
5352 }
5453
55- public String getNewestDateFromString (String input ) {
54+ public String getRelevantDateFromString (String input ) {
5655 //String input = "coming from the 01.12.1988 to the 12.01.2000";
5756 String [] elements = input .split (" " );
5857 DateTimeFormatter f = DateTimeFormatter .ofPattern ("dd.MM.yyyy" );
@@ -65,7 +64,19 @@ public String getNewestDateFromString(String input) {
6564 // Ignore the exception. Move on to next element.
6665 }
6766 }
68- Collections .sort (dates , Collections .reverseOrder ());
67+ //Collections.sort(dates, Collections.reverseOrder());
68+ LocalDate xmin = LocalDate .parse ("2010-01-01" ); //default, ISO_LOCAL_DATE
69+ logger .debug ("XMIN: " +xmin );
70+ // for (LocalDate d : dates){
71+ // if (d.isBefore(xmin))
72+ // dates.remove(d);
73+ // }
74+ for (int i =0 ;i <dates .size ();i ++) {
75+ logger .debug (String .valueOf (dates .get (i )));
76+ if (dates .get (i ).isBefore (xmin ))
77+ dates .remove (i ); // TODO hier weiter
78+ }
79+ Collections .sort (dates );
6980 //System.out.println(dates);
7081 //System.out.println(dates.get(0));
7182 return String .valueOf (dates .get (0 )).replace ("-" ,"_" );
0 commit comments