mirror of
https://github.com/TeamNewPipe/NewPipeExtractor.git
synced 2024-12-14 06:10:33 +05:30
[Bandcamp] Fix deprecation in parseDate helper function
This commit is contained in:
parent
116e921d6c
commit
74b46fed2d
@ -15,9 +15,12 @@ import org.schabi.newpipe.extractor.localization.DateWrapper;
|
||||
import org.schabi.newpipe.extractor.utils.Utils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.time.DateTimeException;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
|
||||
public class BandcampExtractorHelper {
|
||||
|
||||
@ -147,12 +150,12 @@ public class BandcampExtractorHelper {
|
||||
|
||||
static DateWrapper parseDate(final String textDate) throws ParsingException {
|
||||
try {
|
||||
final Date date = new SimpleDateFormat("dd MMM yyyy HH:mm:ss zzz", Locale.ENGLISH).parse(textDate);
|
||||
final Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
return new DateWrapper(calendar, false);
|
||||
} catch (final ParseException e) {
|
||||
throw new ParsingException("Could not extract date", e);
|
||||
final ZonedDateTime zonedDateTime = ZonedDateTime.parse(
|
||||
textDate, DateTimeFormatter.ofPattern("dd MMM yyyy HH:mm:ss zzz", Locale.ENGLISH));
|
||||
return new DateWrapper(zonedDateTime.toOffsetDateTime(), false);
|
||||
} catch (final DateTimeException e) {
|
||||
throw new ParsingException("Could not parse date '" + textDate + "'", e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,10 @@ import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.StreamType;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.Bandcamp;
|
||||
|
Loading…
Reference in New Issue
Block a user