Returning mutable member variables (Date/Timestamp) using getter functions in Java?

Viewed 3489

I have a java class:

class MyObj{
  private Timestamp myDate;

  public  Timestamp getMyDate(){ 
       return mydate;
  }
  ...
}

when I check it by Findbugs, it says:

Bug kind and pattern: EI - EI_EXPOSE_REP May expose internal representation by returning reference to mutable object

so, what is the better way to write the getter for Date and Timestamp types in Java?

2 Answers
Related