How to Format the Value as Float in Form Using Java

104 16
    • 1). Right-click the Java form file that you want to edit. Click "Open With," then click the Java compiler in the list of programs.

    • 2). Locate the float variable you want to format. If you do not already have a float variable defined, use the following code to create the number:

      float money = 19.95;

    • 3). Format the number. The following code shows you how to format the decimal number:

      NumberFormat format = NumberFormat.getCurrencyInstance();

      textfield1.Text = format.format(money);

      Replace "textfield1" with the name of the form text box in which you want to display the formatted number.

Source...
Subscribe to our newsletter
Sign up here to get the latest news, updates and special offers delivered directly to your inbox.
You can unsubscribe at any time

Leave A Reply

Your email address will not be published.