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 ,
android\dalvik\libcore\icu\src\main\java\com\ibm\icu4jni\util
\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
locale

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. gmail on G1

Hi there~

Appears to me each time when I open the gmail application on G1, I get
my email synced back. No need to input my password anymore. Anybody
knows how this is done? Will it be a security hole?

Another thing I tried: I tried to change my gmail account password
through IE, then from G1 gmail reports "no connection", yet I did not
find any place to enter the new password. Is this correct?

thanks,
Dalvik

--~--~---------~--~----~------------~-------~--~----~

2. Polite discussion of lite/trial vs pro distribution

I don't think anyone would flame you on this list.
You had a free app, you made some improvements which cost you this and
that hours of hard work, angry wife, etc.... :) and you want a reward
for that - how this can be wrong?

What I'd do is have the lite version display a dialog on 1st startup,
showing a 1-time notice explaining everything you've just said in a
way that users can understand, including instructions on how to
download and install the previous full-featured free version from your
web site (explaining to users that they have to enable apps from 2rd
party sites, menu paths to do that, etc.).

Don't forget to mention that it can't possibly be your fault that an
imbecile at Google decided that an app's description could fit in 325
chars, and express your confidence that the issue will be fixed by
Google in a timely manner, and asking users politely to file this is a
bug on the Market's forums :)

Cheers




--~--~---------~--~----~------------~-------~--~----~

3. Why would ScrollView not scroll completely?

4. Interrupt testing

5. Problems......

6. Cannot Retrieve Latitude and Longitude without Internet Connection

7. What is the query that need to be done when trying to get Incomming and Outgoing calls ?