There are way too many questions and answers about this basic functionality, I cannot see the wood for the trees.
In Java there is only one simple answer (jav
jav
If you need to handle multiple currencies, various number formats etc. I can recommend autoNumeric. Works a treat. Have been using it successfully for several years now.