This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Try replacing "0.00" with "#.00" or "#.##" to see what effects this has. It's usually a good idea to keep this formatter separate where any class can access it. Agreed - with the caveat that it's not thread-safe, so if you're running multiple threads you need to make sure no two threads are using the same formatter at the same time. Either protect with synchronization, or make sure each thread has its own copy of a formatter. (ThreadLocal may be useful for something like this.) This isn't anything special about NumberFormat really - if you're working with threads you should really be assuming that nothing is thread-safe unless you're guaranteed otherwise, or you've written the code to ensure thread-safety. Probably not really relevant here, but sometime in the future this may bite you if you're not careful, so I thought it worth mentioning. [ May 03, 2003: Message edited by: Jim Yingst ]