Joda-Time Hibernate PersistentYearMonthDay Deprecated

北战南征 提交于 2019-12-12 05:30:05

问题


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?


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/8307593/joda-time-hibernate-persistentyearmonthday-deprecated

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!