Java Code Examples for com.google.api.ads.adwords.axis.v201809.cm.Money#getMicroAmount()

The following examples show how to use com.google.api.ads.adwords.axis.v201809.cm.Money#getMicroAmount() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KeywordOptimizerUtil.java    From keyword-optimizer with Apache License 2.0 5 votes vote down vote up
/**
 * Formats a given monetary value in a default format (2 decimals, padded left to 10 characters).
 *
 * @param money a monetary value
 * @return a string version of the monetary value
 */
public static String format(Money money) {
  long microAmount;
  if (money != null) {
    microAmount = money.getMicroAmount();
  } else {
    return PLACEHOLDER_NULL;
  }

  double amount = (double) microAmount / MICRO_UNITS;
  return String.format(FORMAT_MONEY, amount);
}
 
Example 2
Source File: FormulaContext.java    From keyword-optimizer with Apache License 2.0 5 votes vote down vote up
/**
 * Converts a given {@link Money} object to a number (or NaN if null).
 */
private static double toDoubleOrNaN(Money value) {
  if (value == null || value.getMicroAmount() == null) {
    return Double.NaN;
  }
  return value.getMicroAmount().doubleValue() / 1000000;
}