-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Further beautifying of the print stuff...
Note that the code probably only works with the default printer, will adjust in the future.
- Loading branch information
Showing
3 changed files
with
20 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,20 @@ | ||
package com.rweqx.util; | ||
|
||
import java.text.DecimalFormat; | ||
|
||
public class MathUtil { | ||
|
||
public static double round(double value, int digits){ | ||
return (Math.round(value * Math.pow(10, digits)))/Math.pow(10, digits); | ||
} | ||
|
||
public static String dollarValueFrom(double amount) { | ||
DecimalFormat format; | ||
if(Math.floor(amount) == amount){ | ||
format = new DecimalFormat("#"); | ||
}else { | ||
format = new DecimalFormat("#.00"); | ||
} | ||
return format.format(amount); | ||
} | ||
} |