The simplest one that includes my points below:
public static int usdToCents(BigDecimal usd) { return usd.movePointRight(2).intValueExact(); }
I would recommend intValueExact as this will throw an exception if the information is lost (if you process transactions above $ 21,474,836.47). It can also be used to trap lost fractions.
I also wondered if it was right to accept the value with a fraction of a percent and a round. I would say no, the client code must provide a valid billable amount, so I could do this if I needed a special exception:
public static int usdToCents(BigDecimal usd) { if (usd.scale() > 2)
source share