使用 DateTimeConstants(JodaTime) 值将 dayOfTheWeek 存储在数据库中?
我需要将 dayOfTheWeek 存储在数据库的列中。我使用 HSQLDB。另外,我已经将 JodaTime 用于其他类型,例如时间戳。 我正在考虑将 int 或 string 值封装到一个类中,因此 JodaTIme 已经为常量、星期一、星期二、星期三等提供了 int 值...
这是一个好主意还是坏主意?就像 JodaTime 决定更改天数的值一样 或者我应该存储不同的东西?就像创建我自己的枚举一样......
I need to store a dayOfTheWeek in a column of my database. Im using HSQLDB. Also, Im already using JodaTime for other types, like Timestamp.
Im thinking about encapsulate the int or string values into a class, so JodaTIme has already int values for the Constants, Monday, Tuesday, Wednesday, etc...
Is this a good or bad idea? Like if somewhat JodaTime decides to change the values for the days
Or should I store something different? Like creating my own enum...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
星期几的 int 值由 ISO-8601 定义,并且不会更改。因此,它们可以安全地存储在数据库中。如果您想更进一步,您可以创建一个枚举/类来包装该值,但我认为这并没有真正为 Joda-Time 增加价值(JSR-310/ThreeTen 有一个 DayOfWeek 枚举)。
The int values for day-of-week are defined by ISO-8601 and won't be changing. As such, they are safe to store in a database. If you want to go further, you could create an enum/class to wrap the value, but I don't think that is really adding value with Joda-Time (JSR-310/ThreeTen has a DayOfWeek enum).