Wrong format from String.format()

by GPU » Mon, 06 Sep 2010 15:28:04 GMT

Sponsored Links
 Hi ,
passing two int values m =0 & s = 11, to below function
String formatted = String.format("%1$02d:%2$02d", m, s);

returning the value like   .0:11 ,What could be the problem  ?

m=0, s=11   -->   .0:11
m=0, s=1    -->    .0:.1

The 0 added to format the string always coming as '.' (dot).

Can anyone know ,from where the number patterns are getting loaded in
Android ?

I gone thorough the code ,Its related the following file ,
\Resources.java ->localeData.numberPattern

How the pattern for particular locale is loaded ,what could be the
problem for the above problem?


Wrong format from String.format()

by greg » Tue, 07 Sep 2010 00:18:35 GMT

 Did you want the 1$ and 2$ inside the field width specifications?


Sponsored Links

Wrong format from String.format()

by GPU » Tue, 07 Sep 2010 16:35:39 GMT

 String.format("%1$02d:%2$02d", m, s);
values ,m=0, s=11   -->   .0:11

expected result :   00:11
Actual result from android for Arabic Language :  .0:11

Analysis :
The android external\icu4c
for locale based number pattern  ,It just replacing the zeroDigit()
for padding values only ,the input values(m,n) remain same as US

for arabic decimalPatternChars are below
DecimalFormatSymbols- >localeData.decimalPatternChars:
from above pattern the zeroDigit is \0660 (Arabic 0 digit)
So the output comes as mixed of the arabic & US digits -> .0:11

Is it a bug in Android?!


Other Threads

1. (I'd android)wta setting email gtab

Dear RR
Sesuai subject mau setting email perusahaan ..cmn selalu kebentrok di server 
out telkomsel, ad yg tau ga ya isian telkomsel...thx
blue is hope


2. CyanogenMOD 6.1.2 with SuperBler Kernel di Juned

koq ga ada yang pake SuperBler disini ya ?
mana lebih ok dibanding cyanogen mod 6.1.2 yang bukan superbler




3. On which list item user click

4. I thought you could Build in Flash, and Port to Android with a click?

5. How to update one of views(setText, setImage) in item already added on ListView

6. What changed in Gingerbread as far as the app widgets?

7. display data from database in proper order