Thanks Mark for your reply, but when I include the line you suggested
String t=customFormat("$###,###.###", s);
I don't get an error message but the app crashes at run time. I comment out
the line
and it runs ok. Can you help further please?
On a separate issue. I frequently get a message "unable to open sync
connection" when I try to run my app.
I am using Eclipse. To get around it I restart my computer. I am using a
laptop with approx 1.5Gig memory.
Could you explain what the message means and would more memory help? Also
could you recommend
where I would find a good writeup on string formatting?
Regards
Mike
----- Original Message -----
From: "Mark Murphy" <[email protected]>
To: <[email protected]>
Sent: Saturday, June 13, 2009 7:52 AM
Subject: [android-beginners] Re: String format of numbers into currency
>
> MMC2 wrote:
>> I want to format a number that is held in a string called s to have a
>> leading $ sign and two places after the decimal point. So partly
>> following an example I wrote
>>
>> static public String customFormat(String pattern, String s ) {
>> DecimalFormat myFormatter = new DecimalFormat(pattern);
>> String stringformatoutput = myFormatter.format(s);
>> return stringformatoutput;
>> }
>>
>>
>> then in my code where I went to use this I wrote
>>
>> customFormat("$###,###.###", s);
>> String t = stringformatoutput;
>>
>> hoping to have my formatted string ready for output in t, but I get an
>> error message that stringformatoutput cannot be resolved.
>>
>> Can someone set me straight please
>
> String t=customFormat("$###,###.###", s);
>
> --
> Mark Murphy (a Commons Guy)
> http://commonsware.com | http://twitter.com/commonsguy
>
> Need Android talent? Ask on HADO! http://wiki.andmob.org/hado
>
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---