/**
 * Copyright (C) 2009 - present by OpenGamma Inc. and the OpenGamma group of companies
 *
 * Please see distribution for license.
 */
package com.opengamma.util;

import java.math.BigDecimal;

/**
 * Utility to fix bugs in the JDK.
 * <p>
 * This is a thread-safe static utility class.
 */
public final class JdkUtils {

  /** Singleton zero. */
  private static final BigDecimal ZERO = BigDecimal.valueOf(0, 0);

  /**
   * Restricted constructor.
   */
  private JdkUtils() {
  }

  //-------------------------------------------------------------------------
  /**
   * Strips trailing zeros from a BigDecimal.
   * <p>
   * The JDK does not strip zeros from zero.
   * <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6480539">Bug 6480539</a>.
   * 
   * @param decimal  the big decimal to strip, not null
   * @return the stripped decimal, not null
   */
  public static BigDecimal stripTrailingZeros(final BigDecimal decimal) {
    if (decimal.compareTo(ZERO) == 0) {
      return ZERO;
    } else {
      return decimal.stripTrailingZeros();
    }
  }

}

@@ -322,101 +322,8 @@
  %7B%0A%0A
-  /** Singleton zero. */%0A  private static final BigDecimal ZERO = BigDecimal.valueOf(0, 0);%0A%0A
   /*
@@ -856,12 +856,15 @@
     
-if (
+return 
 deci
@@ -881,66 +881,49 @@
 eTo(
-ZERO) == 0) %7B%0A      return ZERO;%0A    %7D else %7B%0A      return
+BigDecimal.ZERO) == 0 ? BigDecimal.ZERO :
  dec
@@ -953,14 +953,8 @@
 ();%0A
-    %7D%0A
   %7D%0A

Use BigDecimal.ZERO