Decimal values

Mar 28, 2009 at 10:11 PM
Hi,

using the demo application "ui" and also my own frontend for a weight upload, I have not been able to transfer decimal weight values (82.5 kg). The decimal separator "." is just ignored and the weight becomes 825kg. 
This is what my code looks like to create the XML message. DF is a Number Formatter DecimalFormat("0.0", new DecimalFormatSymbols(Locale.US));

infoBuilder.append("<info><thing><type-id>");

        infoBuilder.append(WeightType);

        infoBuilder.append("</type-id><data-xml><weight><when><date><y>");

        infoBuilder.append(calendar.get(Calendar.YEAR));

        infoBuilder.append("</y><m>");

        infoBuilder.append(calendar.get(Calendar.MONTH) + 1);

        infoBuilder.append("</m><d>");

        infoBuilder.append(calendar.get(Calendar.DATE));

        infoBuilder.append("</d></date><time><h>");

        infoBuilder.append(calendar.get(Calendar.HOUR_OF_DAY));

        infoBuilder.append("</h><m>");

        infoBuilder.append(calendar.get(Calendar.MINUTE));

        infoBuilder.append("</m><s>");

        infoBuilder.append(calendar.get(Calendar.SECOND));

        infoBuilder.append("</s></time></when><value><kg>");

        infoBuilder.append(DF.format (e.getWeight_si()));

        infoBuilder.append("</kg></value></weight>");

        infoBuilder.append("<common/></data-xml></thing></info>");


This problem is reproducable with the demo ui wicket application neither , nor . are accepted as decimal separators.


Any clues on this?


Thanks


Moritz

Coordinator
Mar 30, 2009 at 10:35 PM
Edited Mar 31, 2009 at 12:04 AM
The demo ui isn't type aware so I'm baffled as to what you may be encountering.  The demo only passes string values and never parses your input into a decimal.  Any value you input into the text box will be sent to HealthVaul literally.  If you send invalid values to HealthVault, it will reject the input.  What is "e.getWeight_si()".  It doesn't look familiar.

I cannot repro your behavior.  I can send decimals from the ui to HealthVault and back without difficulty. 


Mar 31, 2009 at 6:49 AM
DF.format(e.getWeight_si()) would render as 80.5 if I had a weight value of 80.5 kg stored in my measurement. The resulting XML part would be

<value><kg>80.5</kg></value>

You can see the same behaviour even without using the java library. Just by trying to enter decimal values in the health vault web frontend manually.

Regards

Moritz
Mar 31, 2009 at 5:04 PM
To add on my last post

"You can see the same behaviour even without using the java library. Just by trying to enter decimal values in the health vault web frontend manually."

This is only true when using firefox. With Internet Explorer, one can enter decimal weight values. How strange is this?

Is this maybe an encoding problem? That also applies to my XML message being sent?

Regards

Moritz

Coordinator
Apr 1, 2009 at 8:21 PM
Are you running any language packs or setting different locales in your browser?  I run firefox and am not having any troubles.
Apr 1, 2009 at 8:27 PM
Yes, It's in german localization.