File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
src/main/java/com/olegshan/parser/siteparsers Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -20,10 +20,21 @@ protected LocalDateTime getDateByLine(String dateLine) {
20
20
String [] dateParts = dateLine .split (jobSite .getSplit ());
21
21
MonthsTools .removeZero (dateParts );
22
22
23
- int year = LocalDate .now (ZoneId .of ("Europe/Athens" )).getYear ();
24
- int month = MonthsTools .MONTHS .get (dateParts [1 ].toLowerCase ());
25
23
int day = parseInt (dateParts [0 ]);
24
+ int month = MonthsTools .MONTHS .get (dateParts [1 ].toLowerCase ());
25
+ int year = getYear (month );
26
26
27
27
return LocalDate .of (year , month , day ).atTime (getTime ());
28
28
}
29
+
30
+ //in case we parse in January jobs of last December
31
+ private int getYear (int month ) {
32
+ int year ;
33
+ if (month > LocalDate .now (ZoneId .of ("Europe/Athens" )).getMonthValue ()) {
34
+ year = LocalDate .now ().getYear () - 1 ;
35
+ } else {
36
+ year = LocalDate .now (ZoneId .of ("Europe/Athens" )).getYear ();
37
+ }
38
+ return year ;
39
+ }
29
40
}
You can’t perform that action at this time.
0 commit comments