SimpleDateFormat vs DateFormat vs Joda-Time:Kotlin 应该首选哪一个?

SimpleDateFormat vs DateFormat vs Joda-Time : Which one should be preferred with Kotlin?

哪一个在处理和格式化日期方面效率最高,同时也避免了对第三方组件的不必要依赖?

TL;DR

毫无疑问,java.time、现代日期时间 API 和标准库的一部分,是目前最推荐的选项。

java.util 日期时间 API 及其格式 API、SimpleDateFormat:

java.util 日期时间 API 及其格式 API、SimpleDateFormat (which extends java.text.DateFormat) are outdated and error-prone. It is recommended to stop using them completely and switch to java.time, the modern Date-Time API*.

乔达时间 API:

下面引用的是来自 home page of Joda-Time:

的通知

Note that from Java SE 8 onwards, users are asked to migrate to java.time (JSR-310) - a core part of the JDK which replaces this project.

此外,Joda-Time API 不是 Java 的标准 API;相反,它是第 3 方库。

java.time API:

这是现代的日期时间 API,作为 JSR-310 implementation, to model ISO_8601 standards. You can learn about java.time API from Trail: Date Time.

的一部分随 Java SE 8 一起引入

* 无论出于何种原因,如果您必须坚持Java 6 或Java 7,您可以使用ThreeTen-Backport which backports most of the java.time functionality to Java 6 & 7. If you are working for an Android project and your Android API level is still not compliant with Java-8, check Java 8+ APIs available through desugaring and