Value object getter

Posted by sarah xia on Stack Overflow See other posts from Stack Overflow or by sarah xia
Published on 2010-03-22T02:25:09Z Indexed on 2010/03/22 2:31 UTC
Read the original article Hit count: 430

Filed under:
|

Hi,

I've got a value object, which stores info for example amount. The getAmount() getter returns amount in cents. However in various places, we need to get amount in dollar. There are 2 approaches I can think of:

  1. write a convert method and place it in a utility class.
  2. add a getAmountInDollar() getter in the value object.

I prefer the second approach. What do you think? What are pros and cons of both approaches?

© Stack Overflow or respective owner

Related posts about java

Related posts about getters