Use GMT as base time (actually fix upload date)
This commit is contained in:
parent
b671a4ba18
commit
5756df8dc7
|
@ -4,7 +4,7 @@ import java.text.ParseException;
|
|||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.jsoup.helper.StringUtil;
|
||||
import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException;
|
||||
|
@ -13,22 +13,23 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
|||
import com.grack.nanojson.JsonObject;
|
||||
|
||||
public class PeertubeParsingHelper {
|
||||
|
||||
|
||||
private PeertubeParsingHelper() {
|
||||
}
|
||||
|
||||
public static void validate(JsonObject json) throws ContentNotAvailableException {
|
||||
String error = json.getString("error");
|
||||
if(!StringUtil.isBlank(error)) {
|
||||
if (!StringUtil.isBlank(error)) {
|
||||
throw new ContentNotAvailableException(error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static Calendar parseDateFrom(String textualUploadDate) throws ParsingException {
|
||||
Date date;
|
||||
try {
|
||||
date = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.S'Z'").parse(textualUploadDate);
|
||||
date = new Date(date.getTime() + TimeUnit.HOURS.toMillis(1));
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.S'Z'");
|
||||
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
date = sdf.parse(textualUploadDate);
|
||||
} catch (ParseException e) {
|
||||
throw new ParsingException("Could not parse date: \"" + textualUploadDate + "\"", e);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue