Findbugs issues with mutability of Date object in Java
问题 This is more of a follow-up to questions 1 & 2. As told in the questions the below code public Date getSomeDate() { return someDate; } will give you the findbug error issue. The suggested solution was to duplicate the Date object in both getters and setters like public Date getSomeDate() { return new Date(someDate.getTime()); } Is this a good approach or are there any alternative ways to this? Is there any Immutable Date library available in java that can overcome this issue? 回答1: JodaTime