Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

CXF-2847: fix decimal formatting

git-svn-id: https://svn.apache.org/repos/asf/cxf/trunk@955098 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
commit 8bcdec781f82c4b13709814293b6450295cf1443 1 parent acf3795
@bimargulies bimargulies authored
View
2  rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BigDecimalType.java
@@ -44,6 +44,6 @@ public Object readObject(final MessageReader reader, final Context context) {
@Override
public void writeObject(final Object object, final MessageWriter writer, final Context context) {
- writer.writeValue(object.toString());
+ writer.writeValue(((BigDecimal) object).toPlainString());
}
}
View
37 rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/BigDecimalStringTest.java
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.aegis.type;
+
+import java.math.BigDecimal;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class BigDecimalStringTest {
+
+ @Test
+ public void runMyTest() {
+ BigDecimal scientificNotation = new BigDecimal("0.000000001");
+ assertTrue(scientificNotation.toString().contains("E"));
+ assertFalse(scientificNotation.toPlainString().contains("E"));
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.