|
15 | 15 | import org.schabi.newpipe.extractor.utils.Utils; |
16 | 16 |
|
17 | 17 | import java.io.IOException; |
18 | | -import java.text.ParseException; |
19 | | -import java.text.SimpleDateFormat; |
20 | | -import java.util.*; |
| 18 | +import java.time.DateTimeException; |
| 19 | +import java.time.ZonedDateTime; |
| 20 | +import java.time.format.DateTimeFormatter; |
| 21 | +import java.util.ArrayList; |
| 22 | +import java.util.Arrays; |
| 23 | +import java.util.Locale; |
21 | 24 |
|
22 | 25 | public class BandcampExtractorHelper { |
23 | 26 |
|
@@ -147,12 +150,12 @@ public static boolean isSupportedDomain(final String url) throws ParsingExceptio |
147 | 150 |
|
148 | 151 | static DateWrapper parseDate(final String textDate) throws ParsingException { |
149 | 152 | try { |
150 | | - final Date date = new SimpleDateFormat("dd MMM yyyy HH:mm:ss zzz", Locale.ENGLISH).parse(textDate); |
151 | | - final Calendar calendar = Calendar.getInstance(); |
152 | | - calendar.setTime(date); |
153 | | - return new DateWrapper(calendar, false); |
154 | | - } catch (final ParseException e) { |
155 | | - throw new ParsingException("Could not extract date", e); |
| 153 | + final ZonedDateTime zonedDateTime = ZonedDateTime.parse( |
| 154 | + textDate, DateTimeFormatter.ofPattern("dd MMM yyyy HH:mm:ss zzz", Locale.ENGLISH)); |
| 155 | + return new DateWrapper(zonedDateTime.toOffsetDateTime(), false); |
| 156 | + } catch (final DateTimeException e) { |
| 157 | + throw new ParsingException("Could not parse date '" + textDate + "'", e); |
156 | 158 | } |
| 159 | + |
157 | 160 | } |
158 | 161 | } |
0 commit comments