15
15
16
16
import java .io .IOException ;
17
17
import java .time .LocalDate ;
18
+ import java .time .LocalDateTime ;
19
+ import java .time .LocalTime ;
18
20
19
21
/**
20
22
* Created by olegshan on 03.10.2016.
@@ -55,7 +57,7 @@ public void parse(JobService jobService,
55
57
String title = titleBlock .text ();
56
58
String description = job .getElementsByAttributeValue (descriptionData [0 ], descriptionData [1 ]).text ();
57
59
String company = getCompany (jobService , job , url , companyData );
58
- LocalDate date = getDate (jobService , url , dateData , titleBlock , job );
60
+ LocalDateTime date = getDate (jobService , url , dateData , titleBlock , job );
59
61
60
62
Job parsedJob = new Job (title , description , company , siteName , url , date );
61
63
jobRepository .save (parsedJob );
@@ -111,8 +113,8 @@ private Elements getTitleBlock(JobService jobService, Element job, String[] titl
111
113
return titleBlock ;
112
114
}
113
115
114
- private LocalDate getDate (JobService jobService , String url , String [] dateData , Elements titleBlock , Element job ) {
115
- LocalDate date ;
116
+ private LocalDateTime getDate (JobService jobService , String url , String [] dateData , Elements titleBlock , Element job ) {
117
+ LocalDateTime date ;
116
118
String dateLine ;
117
119
if (jobService instanceof DouService ) {
118
120
Document dateDoc = getDoc (url );
@@ -131,7 +133,7 @@ private LocalDate getDate(JobService jobService, String url, String[] dateData,
131
133
return date ;
132
134
}
133
135
134
- private LocalDate getDateByLine (JobService jobService , String dateLine ) {
136
+ private LocalDateTime getDateByLine (JobService jobService , String dateLine ) {
135
137
String [] dateParts ;
136
138
int year ;
137
139
int month ;
@@ -155,10 +157,10 @@ private LocalDate getDateByLine(JobService jobService, String dateLine) {
155
157
if (jobService instanceof DouService || jobService instanceof HeadHunterService ) {
156
158
month = MonthsTools .MONTHS .get (dateParts [1 ].toLowerCase ());
157
159
} else month = Integer .parseInt (dateParts [1 ]);
158
- return LocalDate .of (year , month , day );
160
+ return LocalDate .of (year , month , day ). atTime ( LocalTime . now ()) ;
159
161
}
160
162
161
- private LocalDate getDateForRabotaUa (String url ) {
163
+ private LocalDateTime getDateForRabotaUa (String url ) {
162
164
/*
163
165
* There are several problems here.
164
166
* First: there are two types of date tags, used on the site on different pages: "d-date" and "datePosted".
@@ -181,7 +183,7 @@ private LocalDate getDateForRabotaUa(String url) {
181
183
dateLine = dateDoc .getElementsByAttributeValue ("itemprop" , "datePosted" ).text ();
182
184
if (dateLine .length () == 0 ) {
183
185
//no date at all, sometimes it happens
184
- return LocalDate .now ();
186
+ return LocalDateTime .now ();
185
187
}
186
188
}
187
189
try {
@@ -199,7 +201,7 @@ private LocalDate getDateForRabotaUa(String url) {
199
201
month = Integer .parseInt (dateParts [1 ]);
200
202
day = Integer .parseInt (dateParts [2 ]);
201
203
}
202
- return LocalDate .of (year , month , day );
204
+ return LocalDate .of (year , month , day ). atTime ( LocalTime . now ()) ;
203
205
}
204
206
205
207
private String getCompany (JobService jobService , Element job , String url , String [] companyData ) {
0 commit comments