Files
EasyDrop/src/main/java/de/rwu/easydrop/util/FormattingUtil.java
2023-05-31 13:47:08 +02:00

41 lines
977 B
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) + "";
}
/**
* 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(" ", "+");
}
}