From 87732f17935f139721c8dd1d38397327660b75e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E6=84=8F=E5=B8=86?= <1657098617@qq.com> Date: Sat, 14 May 2022 23:19:51 +0800 Subject: [PATCH] =?UTF-8?q?fix:=201.=20=E4=BF=AE=E5=A4=8DWebDav=E4=B8=AD?= =?UTF-8?q?=E7=9A=84=E6=97=B6=E9=97=B4=E5=AD=97=E6=AE=B5=E8=A7=A3=E6=9E=90?= =?UTF-8?q?BUG=202.=20=E8=B0=83=E6=95=B4=E6=97=B6=E9=97=B4=E8=BD=AC?= =?UTF-8?q?=E6=8D=A2=E7=B1=BB=E4=B8=BA=20DateTimeFormatter=20+=20LocalDate?= =?UTF-8?q?Time=20=E7=9A=84=E7=BA=BF=E7=A8=8B=E5=AE=89=E5=85=A8=E7=BB=84?= =?UTF-8?q?=E5=90=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/lib/webdav/WebDav.kt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/io/legado/app/lib/webdav/WebDav.kt b/app/src/main/java/io/legado/app/lib/webdav/WebDav.kt index d27e731de..04d152845 100644 --- a/app/src/main/java/io/legado/app/lib/webdav/WebDav.kt +++ b/app/src/main/java/io/legado/app/lib/webdav/WebDav.kt @@ -19,14 +19,16 @@ import java.io.InputStream import java.net.MalformedURLException import java.net.URL import java.net.URLEncoder -import java.text.SimpleDateFormat +import java.time.LocalDateTime +import java.time.ZoneOffset +import java.time.format.DateTimeFormatter @Suppress("unused", "MemberVisibilityCanBePrivate") open class WebDav(urlStr: String, val authorization: Authorization) { companion object { - @SuppressLint("SimpleDateFormat") - private val dateFormat = SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss ZZZ") + @SuppressLint("DateTimeFormatter") + private val dateTimeFormatter = DateTimeFormatter.RFC_1123_DATE_TIME // 指定返回哪些属性 @Language("xml") @@ -133,11 +135,11 @@ open class WebDav(urlStr: String, val authorization: Authorization) { .firstOrNull()?.text()?.toLong() ?: 0 }.getOrDefault(0) val lastModify: Long = kotlin.runCatching { - element.getElementsByTag("d:getcontentlength") + element.getElementsByTag("d:getlastmodified") .firstOrNull()?.text()?.let { - dateFormat.parse(it) + LocalDateTime.parse(it, dateTimeFormatter).toInstant(ZoneOffset.of("+8")).toEpochMilli() } - }.getOrNull()?.time ?: 0 + }.getOrNull() ?: 0 webDavFile = WebDavFile( baseUrl + fileName, authorization,