Source Code : Parse a number using a NumberFormat
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
Parse a number using a NumberFormat
import java.text.NumberFormat;
import java.text.ParseException;
/*
* Parse a number using a NumberFormat.
*/
public class NumFormatParse {
//+
/** A number to parse */
public static final String input = "4096.251";
//-
/** The main (and only) method in this class. */
public static void main(String[] av) {
//+
NumberFormat defForm = NumberFormat.getInstance();
try {
Number d = defForm.parse(input);
System.out.println(input +
" parses as " + d +
" and formats as " + defForm.format(d));
} catch (ParseException pe) {
System.err.println(input + "not parseable!");
}
//-
}
}
Thank with us