Joda-Time Hibernate PersistentYearMonthDay 已弃用

发布于 2024-12-18 12:52:48 字数 421 浏览 3 评论 0原文

在查看 Joda-Time Hibernate 用户指南 时,似乎有未来不再支持 SQL DATE 类型。由于 TIMESTAMP 被指定为从 1970 年 1 月 1 日开始 - 1970 年之前日期的唯一安全传输似乎是 VARCHAR 和 PercientLocalTimeAsString(如果希望将自己限制在 Joda Hibernate 库中)。

作为使用 DATE 的人(并且看到 Joda Hibernate 不是),我想知道是否有某种原因我应该切换到 VARCHAR 和 PersistentLocalTimeAsString。 IE。是什么促使我们决定弃用 PersistentYearMonthDay?

In looking through the Joda-Time Hibernate user guide it appears that there is no future support for the SQL DATE type. Since TIMESTAMP is specified to start on Jan 1, 1970 - the only safe transport for dates before 1970 appears to be VARCHAR with PersistentLocalTimeAsString (if one wishes to restrict themselves to the Joda Hibernate library).

As someone who uses DATE (and seeing that Joda Hibernate isn't) I am wondering if there is some reason I should switch to VARCHAR and PersistentLocalTimeAsString. Ie. what motivated the decision to deprecate PersistentYearMonthDay?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

允世 2024-12-25 12:52:48

它不是从 1970 年开始,它是一个零点,但它可能是负数。弃用 PersistentYearMonthDay 的原因是弃用 年月日。动机是“使用 LocalDate,它具有更好的内部实现,并且自 1.3 起就可用

另外,这很奇怪,但是 PersistentLocalDate 的源代码具有 DATE sql 类型,而用户指南显示 TIMESTAMP,请尝试一下,也许只是用户指南中的拼写错误。

It doesn't start on 1970, it's a zero point, but it could be negative. The reason why the PersistentYearMonthDay deprecated is deprecation of YearMonthDay. Motivated as "Use LocalDate which has a much better internal implementation and has been available since 1.3"

Also, it's weird, but the source code for the PersistentLocalDate has DATE sql type, while the user guide says TIMESTAMP, try it, maybe just a typo in the user guide.

烟织青萝梦 2024-12-25 12:52:48
long someTimeBefore1970 = -83688769L;
Timestamp ts = new Timestamp(someTimeBefore1970);
System.out.println(ts);

0 设置为 1970 年 1 月 1 日,但这并不意味着不支持之前的日期。

long someTimeBefore1970 = -83688769L;
Timestamp ts = new Timestamp(someTimeBefore1970);
System.out.println(ts);

The 0 is set to the 1st Jan. 1970, but that doesn't mean that dates before aren't supported.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文