Look up DecimalFormat You'll need to create the format on that object: String pattern = "0.##"; // or "0.00" depending if you want 1.5 to show a 1.5 or 1.50 DecimalFormat my_formatter = new DecimalFormat (pattern); String formatted_string = my_formatter.format (1.23456789)
You could put the pattern directly into the constructor to only take 2 lines of code instead of 3. -Kitzy On Mar 6, 8:18 am, BobG <bobgard...@aol.com> wrote: > What shows: 1.23456789 > What I want: 1.23 > In c it would be printf("%4.2f",n); > In Java its? (I dont know yet). > Thanks! -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en