Last updated by Roedy Green ©1996-1999 Canadian Mind Products.
Stuck in a frame? Click here to break out.
| Newsgroup | Purpose |
|---|---|
| comp.lang.java.advocacy | Java politics, comparisons with other languages, exchanging juvenile insults, suggested changes to the language. |
| comp.lang.java.databases | SQL, JDBC and other databases. |
| comp.lang.java.gui | intermediate and advanced AWT and Swing questions. |
| comp.lang.java.help | Newbie questions. |
| comp.lang.java.machine | The JVM internals, garbage collection, Java chips. |
| comp.lang.java.programmer | Advanced programming questions not about the GUI, e.g. serialization, RMI, CORBA, reflection, security sandbox and jar signing. |
| comp.lang.java.softwaretools | Tools and libraries. Bugs in various IDEs. |
// get an conversion object customised for a particular locale
java.text.NumberFormat nf = java.text.NumberFormat.getInstance();
// set whether you want commas (or locale equivalent) inserted
nf.setGroupingUsed(true);
// set how many places you want to the right of the decimal.
nf.setMinimumFractionDigits(3);
nf.setMaximumFractionDigits(3);
// set how many places you want to the left of the decimal.
nf.setMinimumIntegerDigits(1);
nf.setMaximumIntegerDigits(10);
// convert from binary to String
String s1 = nf.format(1234L); // will produce 1,234.000 not 1.234 !!
String s2 = nf.format(1.234D); // will produce 1.234
// convert from String to binary
Number n1 = null;
Number n2 = null;
try {
n1 = nf.parse("1,234"); // will produce a Long 1234L
n2 = nf.parse("1.234"); // will produce a Double 1.234D
} catch (java.text.ParseException e) {}![]() |
![]() | ||
| Canadian Mind Products | You can get an updated copy of this page from http://mindprod.com/jglossn.html | The Mining Company's
Focus on Java Best of the Net Award |