Project

Profile

Help

Bug #4698

closed

Constructor XdmAtomicValue(decimal d) should use d.ToString(CultureInfo.InvariantCulture) instead of d.ToString()

Added by Martin Honnen over 3 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Normal
Category:
.NET API
Sprint/Milestone:
-
Start date:
2020-08-27
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
10, 9.9, trunk
Fix Committed on Branch:
10, 9.9, trunk
Fixed in Maintenance Release:
Platforms:

Description

I have run into a problem with the construction of an xs:decimal from a .NET decimal, as I have a German version of Windows 10 usually .NET code runs with that CultureInfo for that language meaning in

    public XdmAtomicValue(decimal d)
    {
        this.value = new JBigDecimalValue(new JBigDecimal(d.ToString()));
    }

the call of d.ToString() where var d = 2.5m; gives 2,5 and not 2.5. Subsequently the Java parsing of the 2,5 fails with

Unbehandelte Ausnahme: java.lang.NumberFormatException
   bei java.math.BigDecimal..ctor(Char[] in, Int32 offset, Int32 len, MathContext mc)
   bei java.math.BigDecimal..ctor(Char[] in, Int32 offset, Int32 len)
   bei java.math.BigDecimal..ctor(String val)
   bei Saxon.Api.XdmAtomicValue..ctor(Decimal d)

So I think the constructor needs to be fixed to use d.ToString(CultureInfo.InvariantCulture).

Please register to edit this issue

Also available in: Atom PDF