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. Bug? LocationMasfClient / GPS keeps sending updates even after locationmanager.removeupdates?

Ok, I am using GPS on Google maps, and this is my onPause. Am I
missing something? GPS keeps sending

LocationMasfClient getNetworkLocation(): Returning cache location with
accuracy 1319.0

Then eventually it does :
GPSLocationProvider state: DISCONNECTED apnName: null reason: null.

Am I missing something?

    public void onPause(){
      // Suspend UI updates, threads, or CPU intensive processes that
      // need to be updated when the Activity isn the active
foreground activity.



2. js painfully slow on 1.5


i heard somewhere that cupcake has brand new, very fast javascript

recently i tried to use jquery and in my opinion it's not fast: i
tried local (stored in assets folder) version of smallest possible i
could get (packed v1.1.2) and it seems that loading it takes ~5sec.
this is when i run it on the emulator.

maybe g1 works better, could anybody, please, check it out?


3. develop a simple game like tic toc

4. How to know how long the key is pressed?

5. Email App and IM App on cupcake branch

6. modifying a Listview after onCreate (at buttonclick).

7. Checking the Hardware (Phone model) programatically