#39 Added basic implementation
This commit is contained in:
@@ -1,5 +1,39 @@
|
||||
package de.rwu.easydrop.util;
|
||||
|
||||
public class FormattingUtil {
|
||||
import java.text.NumberFormat;
|
||||
import java.util.Currency;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Helps format a bunch of things.
|
||||
*
|
||||
* @since 0.1.0
|
||||
*/
|
||||
public final class FormattingUtil {
|
||||
|
||||
/**
|
||||
* Private constructor to prevent unwanted instantiation.
|
||||
*
|
||||
* @throws UnsupportedOperationException always
|
||||
*/
|
||||
private FormattingUtil() throws UnsupportedOperationException {
|
||||
throw new UnsupportedOperationException("This is a utility class, don't instantiate it.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a price to the German Euro format.
|
||||
*
|
||||
* @param amount price
|
||||
* @return formatted price
|
||||
*/
|
||||
public static String formatEuro(final double amount) {
|
||||
// Set up environment
|
||||
Locale locale = Locale.GERMANY;
|
||||
Currency currency = Currency.getInstance("EUR");
|
||||
NumberFormat numberFormat = NumberFormat.getCurrencyInstance(locale);
|
||||
|
||||
numberFormat.setCurrency(currency);
|
||||
|
||||
return numberFormat.format(amount);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user