Merge pull request #454 from Isira-Seneviratne/Fix_date_time_issues
Fix some issues related to the date/time changes.
This commit is contained in:
commit
b42a196f35
|
@ -28,8 +28,7 @@ public class DateWrapper implements Serializable {
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public DateWrapper(@NonNull Calendar calendar, boolean isApproximation) {
|
public DateWrapper(@NonNull Calendar calendar, boolean isApproximation) {
|
||||||
offsetDateTime = OffsetDateTime.ofInstant(calendar.toInstant(), ZoneOffset.UTC);
|
this(OffsetDateTime.ofInstant(calendar.toInstant(), ZoneOffset.UTC), isApproximation);
|
||||||
this.isApproximation = isApproximation;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DateWrapper(@NonNull OffsetDateTime offsetDateTime) {
|
public DateWrapper(@NonNull OffsetDateTime offsetDateTime) {
|
||||||
|
|
|
@ -21,7 +21,9 @@ import java.io.UnsupportedEncodingException;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.time.OffsetDateTime;
|
import java.time.OffsetDateTime;
|
||||||
|
import java.time.ZoneOffset;
|
||||||
import java.time.format.DateTimeParseException;
|
import java.time.format.DateTimeParseException;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -184,7 +186,11 @@ public class YoutubeParsingHelper {
|
||||||
try {
|
try {
|
||||||
return OffsetDateTime.parse(textualUploadDate);
|
return OffsetDateTime.parse(textualUploadDate);
|
||||||
} catch (DateTimeParseException e) {
|
} catch (DateTimeParseException e) {
|
||||||
throw new ParsingException("Could not parse date: \"" + textualUploadDate + "\"", e);
|
try {
|
||||||
|
return LocalDate.parse(textualUploadDate).atStartOfDay().atOffset(ZoneOffset.UTC);
|
||||||
|
} catch (DateTimeParseException e1) {
|
||||||
|
throw new ParsingException("Could not parse date: \"" + textualUploadDate + "\"", e1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@ import org.schabi.newpipe.extractor.stream.StreamType;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.time.OffsetDateTime;
|
import java.time.OffsetDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.time.format.DateTimeParseException;
|
import java.time.format.DateTimeParseException;
|
||||||
|
|
||||||
public class YoutubeFeedInfoItemExtractor implements StreamInfoItemExtractor {
|
public class YoutubeFeedInfoItemExtractor implements StreamInfoItemExtractor {
|
||||||
|
@ -61,7 +60,7 @@ public class YoutubeFeedInfoItemExtractor implements StreamInfoItemExtractor {
|
||||||
@Override
|
@Override
|
||||||
public DateWrapper getUploadDate() throws ParsingException {
|
public DateWrapper getUploadDate() throws ParsingException {
|
||||||
try {
|
try {
|
||||||
return new DateWrapper(OffsetDateTime.parse(getTextualUploadDate(), DateTimeFormatter.ISO_OFFSET_DATE_TIME));
|
return new DateWrapper(OffsetDateTime.parse(getTextualUploadDate()));
|
||||||
} catch (DateTimeParseException e) {
|
} catch (DateTimeParseException e) {
|
||||||
throw new ParsingException("Could not parse date (\"" + getTextualUploadDate() + "\")", e);
|
throw new ParsingException("Could not parse date (\"" + getTextualUploadDate() + "\")", e);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue