|
17 | 17 | import java.time.LocalDate;
|
18 | 18 | import java.time.LocalDateTime;
|
19 | 19 | import java.time.LocalTime;
|
| 20 | +import java.time.temporal.ChronoField; |
20 | 21 |
|
21 | 22 | /**
|
22 | 23 | * Created by olegshan on 03.10.2016.
|
23 | 24 | */
|
24 | 25 | @Component
|
25 | 26 | public class Parser {
|
26 | 27 |
|
| 28 | + private static final int HOUR = LocalDateTime.now().get(ChronoField.HOUR_OF_DAY); |
27 | 29 | @Autowired
|
28 | 30 | private JobRepository jobRepository;
|
29 | 31 |
|
@@ -61,7 +63,7 @@ public void parse(JobService jobService,
|
61 | 63 | }
|
62 | 64 |
|
63 | 65 | private Document getDoc(String siteToParse) {
|
64 |
| - Document doc = null; |
| 66 | + Document doc; |
65 | 67 | try {
|
66 | 68 | doc = Jsoup.connect(siteToParse).userAgent("Mozilla").timeout(0).get();
|
67 | 69 | } catch (IOException e) {
|
@@ -160,7 +162,7 @@ private LocalDateTime getDateByLine(JobService jobService, String dateLine) {
|
160 | 162 | if (jobService instanceof DouService || jobService instanceof HeadHunterService) {
|
161 | 163 | month = MonthsTools.MONTHS.get(dateParts[1].toLowerCase());
|
162 | 164 | } else month = Integer.parseInt(dateParts[1]);
|
163 |
| - return LocalDate.of(year, month, day).atTime(LocalTime.now()); |
| 165 | + return LocalDate.of(year, month, day).atTime(LocalTime.of(HOUR, 0, 0)); |
164 | 166 | }
|
165 | 167 |
|
166 | 168 | private LocalDateTime getDateForRabotaUa(String url) {
|
@@ -204,7 +206,7 @@ private LocalDateTime getDateForRabotaUa(String url) {
|
204 | 206 | month = Integer.parseInt(dateParts[1]);
|
205 | 207 | day = Integer.parseInt(dateParts[2]);
|
206 | 208 | }
|
207 |
| - return LocalDate.of(year, month, day).atTime(LocalTime.now()); |
| 209 | + return LocalDate.of(year, month, day).atTime(LocalTime.of(HOUR, 0, 0)); |
208 | 210 | }
|
209 | 211 |
|
210 | 212 | private String getCompany(JobService jobService, Element job, String url, String[] companyData) {
|
|
0 commit comments