Using DateTimeConstants(JodaTime) value to store dayOfTheWeek in database?
I need to store a dayOfTheWeek in a column of my database. Im using HSQ开发者_如何转开发LDB. 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...
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).
精彩评论