Free Courses | Free Gallery | Free Library | Free FAQS | Free Links | Free Speech |
|
Free Java Package: util Brief:NumUtil class only have one static method in it- toMoneyFormat which basically formats any double into two decimal places. StringUtil includes a function which would escape a string so that it is HTML compatible. Suggested additions include method isPrime() which would determine whether a certain positive integer is prime or not using the fastest algorithm available. Program Listing
How to use: System.out.println(NumUtil.toMoneyFormat(10.0263423, true)); System.out.println(NumUtil.toMoneyFormat(10.0263423, false)); System.out.println(NumUtil.toMoneyFormat(10, false)); System.out.println(NumUtil.toMoneyFormat(10.9, false)); System.out.println(NumUtil.toMoneyFormat(99999999, false)); System.out.println(StringUtil.cleanHTMLStr("& <>1235345sadfwerewzvxc")); Known limitation: toMoneyFormat can only format numbers which are not more than 9999999 because numbers that are greater than that would be expressed in scientific notation. Download this package including the example files in here. |