51 lines
1.2 KiB
Java
51 lines
1.2 KiB
Java
package de.rwu.easydrop.util;
|
|
|
|
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) {
|
|
return String.format(Locale.GERMAN, "%,.2f", amount) + " Euro";
|
|
}
|
|
|
|
/**
|
|
* Makes a string URL ready. For now, only spaces are replaced.
|
|
*
|
|
* @param str
|
|
* @return URL-ready string
|
|
*/
|
|
public static String urlEncode(final String str) {
|
|
return str.replace(" ", "+");
|
|
}
|
|
|
|
/**
|
|
* Removes spaces from target string.
|
|
*
|
|
* @param str String
|
|
* @return Space-less string
|
|
*/
|
|
public static String removeSpaces(final String str) {
|
|
return str.replace(" ", "");
|
|
}
|
|
}
|