Skip to content

Commit 5b5a644

Browse files
committed
Replace joda-time with java.time
Fix gitbucket#1513
1 parent fa2d7db commit 5b5a644

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

build.sbt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ libraryDependencies ++= Seq(
4141
"org.apache.sshd" % "apache-sshd" % "1.4.0" exclude("org.slf4j","slf4j-jdk14"),
4242
"org.apache.tika" % "tika-core" % "1.14",
4343
"com.github.takezoe" %% "blocking-slick-32" % "0.0.10",
44-
"joda-time" % "joda-time" % "2.9.9",
4544
"com.novell.ldap" % "jldap" % "2009-10-07",
4645
"com.h2database" % "h2" % "1.4.195",
4746
"org.mariadb.jdbc" % "mariadb-java-client" % "2.1.2",

doc/licenses.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ Category | License | Dependency | Notes
44
--- | --- | --- | ---
55
Apache | [ Apache License, Version 2.0 ]( http://opensource.org/licenses/apache2.0.php ) | org.osgi # org.osgi.core # 4.3.1 | <notextile></notextile>
66
Apache | [Apache 2](http://www.apache.org/licenses/LICENSE-2.0.txt) | com.googlecode.javaewah # JavaEWAH # 1.1.6 | <notextile></notextile>
7-
Apache | [Apache 2](http://www.apache.org/licenses/LICENSE-2.0.txt) | joda-time # joda-time # 2.9.9 | <notextile></notextile>
87
Apache | [Apache 2](http://www.apache.org/licenses/LICENSE-2.0) | org.cache2k # cache2k-all # 1.0.0.CR1 | <notextile></notextile>
98
Apache | [Apache 2](http://www.apache.org/licenses/LICENSE-2.0.txt) | org.objenesis # objenesis # 2.5 | <notextile></notextile>
109
Apache | [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0) | org.apache.sshd # apache-sshd # 1.4.0 | <notextile></notextile>

src/main/scala/gitbucket/core/api/JsonFormat.scala

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
package gitbucket.core.api
22

3-
import org.joda.time.DateTime
4-
import org.joda.time.DateTimeZone
5-
import org.joda.time.format._
6-
import org.json4s._
7-
import org.json4s.jackson.Serialization
3+
import java.time._
4+
import java.time.format.DateTimeFormatter
85
import java.util.Date
6+
97
import scala.util.Try
108

9+
import org.json4s._
10+
import org.json4s.jackson.Serialization
11+
1112
object JsonFormat {
1213

1314
case class Context(baseUrl: String, sshUrl: Option[String])
1415

15-
val parserISO = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss'Z'")
16+
val parserISO = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss'Z'")
1617

1718
val jsonFormats = Serialization.formats(NoTypeHints) + new CustomSerializer[Date](format =>
1819
(
19-
{ case JString(s) => Try(parserISO.parseDateTime(s)).toOption.map(_.toDate).getOrElse(throw new MappingException("Can't convert " + s + " to Date")) },
20-
{ case x: Date => JString(parserISO.print(new DateTime(x).withZone(DateTimeZone.UTC))) }
20+
{ case JString(s) => Try(Date.from(Instant.parse(s))).getOrElse(throw new MappingException("Can't convert " + s + " to Date")) },
21+
{ case x: Date => JString(OffsetDateTime.ofInstant(x.toInstant, ZoneId.of("UTC")).format(parserISO)) }
2122
)
2223
) + FieldSerializer[ApiUser]() +
2324
FieldSerializer[ApiPullRequest]() +

src/main/scala/gitbucket/core/controller/RepositorySettingsController.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package gitbucket.core.controller
22

3+
import java.time.{LocalDateTime, ZoneId, ZoneOffset}
4+
import java.util.Date
5+
36
import gitbucket.core.settings.html
4-
import gitbucket.core.model.{WebHook, RepositoryWebHook}
7+
import gitbucket.core.model.{RepositoryWebHook, WebHook}
58
import gitbucket.core.service._
69
import gitbucket.core.service.WebHookService._
710
import gitbucket.core.util._
@@ -175,7 +178,8 @@ trait RepositorySettingsControllerBase extends ControllerBase {
175178
redirect(s"/${repository.owner}/${repository.name}/settings/branches")
176179
} else {
177180
val protection = ApiBranchProtection(getProtectedBranchInfo(repository.owner, repository.name, branch))
178-
val lastWeeks = getRecentStatuesContexts(repository.owner, repository.name, org.joda.time.LocalDateTime.now.minusWeeks(1).toDate).toSet
181+
val lastWeeks = getRecentStatuesContexts(repository.owner, repository.name,
182+
Date.from(LocalDateTime.now.minusWeeks(1).toInstant(ZoneOffset.of("UTC")))).toSet
179183
val knownContexts = (lastWeeks ++ protection.status.contexts).toSeq.sortBy(identity)
180184
html.branchprotection(repository, branch, protection, knownContexts, flash.get("info"))
181185
}

0 commit comments

Comments
 (0)