Package de.frankmuenster.mahoe.utils
Class Utils
java.lang.Object
de.frankmuenster.mahoe.utils.Utils
Utility-Klasse
- Author:
- Frank Münster
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ThreadLocal<DecimalFormat>Dezimal-Format mit genau 2 Nachkommastellenstatic final doubleThe difference below which doubles should be treated as equal numbersstatic final StringTextual boolean truestatic final StringTextual boolean false -
Method Summary
Modifier and TypeMethodDescriptionstatic StringconvertDoubleToString(Double doubleValue) Formatiert einen Double-Wert in einen String mit genau 2 Nachkommastellen.static StringconvertLocalDateTimeToString(LocalDateTime dateTime, String format) LocalDateTime to String converterstatic StringLocalDate to String converter.static StringconvertLocalDateToString(LocalDate date, String format) LocalDate to String converterstatic BigDecimalconvertStringToBigDecimal(String doubleString) Remove EUR, EUR sign and thousand separator from given double string.static DoubleconvertStringToDouble(String doubleString) Remove EUR and tausend separator from given double string.static DateconvertTextToDate(String text, String format) Text to Date converterstatic LocalDateconvertTextToLocalDate(String text, String format) String to LocalDate converterstatic LocalDatedateToLocalDate(Date date) static booleangetBooleanFromYesNoString(String yesNo) Returns "true" in case the String is "JA", "false" else.static Class<?>[]getClasses(String packageName) Scans all classes accessible from the context class loader which belong to the given package and sub packages.static de.willuhn.jameica.hbci.rmi.KontoLiefert ein Konto zu den angegeben ID.static DategetLastUmsatzDate(de.willuhn.jameica.hbci.rmi.Konto konto, Calendar startDate) Liefert das Datum, ab wann die Umsätze geladen werden sollen.static StringgetYesNoStringFromBoolean(boolean yesNo) Returns the String object "JA" or "NEIN" depending on the given boolean value.static StringibanFormater(String iban) Fügt einer IBAN ein Leerzeichen an jeder 4 Stelle hinzu.static voidloadUmsatz(de.willuhn.jameica.hbci.rmi.Umsatz umsatz, String umsatzString) Läd einen Umsatz-Beschreibungstext in einen Umsatz.static DatelocalDateToDate(LocalDate localDate) static StringmaskCardNummer(String kartenNummer) Maskiert eine Karten-Nummer und zeigt nur die letzten 4 Ziffernstatic voidnotifyUsers(String message) Display a message to the users.static DatenowMinusDays(int days) Returns theDatewith the given offset in the paststatic DateparseOrNull(DateFormat dateFormatter, String value) Parse a date string with the given parser and either return the parsed date or NULL.static StringEntfernt einen Zeilenumbruch am Ende einer Zeile.static voidremovePdfMeta(de.willuhn.jameica.hbci.rmi.Konto account) Removes deprecated Kontoauszugs-PDF META information from an account.static StringreplaceUmlauts(String text) Ersetzt alle deutschen Umlaute mit den deutschen Entsprechungen.static BigDecimalroundDoubleToBigDecimal(double number, int digits) Rundet auf die angegebene Anzahl Nachkommastellenstatic doubleroundNumber(double number, int digits) Rundet auf die angegebene Anzahl Nachkommastellenstatic voidsetProxyCfg(org.htmlunit.WebClient webClient, String url) Setzt die Proxy-Einstellungenstatic voidwaitIgnoreThreadInterrupts(long millis) Waits for the given but doesn't handle a InterruptedException.
-
Field Details
-
DECIMAL_FORMAT
Dezimal-Format mit genau 2 Nachkommastellen -
DOUBLE_TREAT_AS_EQUAL
public static final double DOUBLE_TREAT_AS_EQUALThe difference below which doubles should be treated as equal numbers- See Also:
-
TEXT_JA
Textual boolean true- See Also:
-
TEXT_NEIN
Textual boolean false- See Also:
-
-
Method Details
-
convertDoubleToString
Formatiert einen Double-Wert in einen String mit genau 2 Nachkommastellen.- Parameters:
doubleValue- der Double-Wert der Konvertiert werden soll.- Returns:
- die konvertierte Zahl als String
-
convertLocalDateTimeToString
public static String convertLocalDateTimeToString(LocalDateTime dateTime, String format) throws DateTimeParseException LocalDateTime to String converter- Parameters:
dateTime-format-- Throws:
ParseExceptionDateTimeParseException
-
convertLocalDateToString
LocalDate to String converter. The default format dd.MM.yyyy will be used.- Parameters:
date- the date to convert- Throws:
ParseException
-
convertLocalDateToString
public static String convertLocalDateToString(LocalDate date, String format) throws DateTimeParseException LocalDate to String converter- Parameters:
date-format-- Throws:
ParseExceptionDateTimeParseException
-
convertStringToBigDecimal
Remove EUR, EUR sign and thousand separator from given double string. Replaces German , to . to represent double in good format.- Parameters:
doubleString- der String der Konvertiert werden soll- Returns:
- die konvertierte Zahl
-
convertStringToDouble
Remove EUR and tausend separator from given double string. Replaces German , to . to represent double in good format.- Parameters:
doubleString- der String der Konvertiert werden soll- Returns:
- die konvertierte Zahl
-
convertTextToDate
Text to Date converter- Throws:
ParseException
-
convertTextToLocalDate
public static LocalDate convertTextToLocalDate(String text, String format) throws DateTimeParseException String to LocalDate converter- Throws:
ParseExceptionDateTimeParseException
-
dateToLocalDate
-
getBooleanFromYesNoString
Returns "true" in case the String is "JA", "false" else.- Parameters:
yesNo- the String to analyse- Returns:
- "
true" in case the String is "JA", "false" else.
-
getClasses
Scans all classes accessible from the context class loader which belong to the given package and sub packages.- Parameters:
packageName- The base package- Returns:
- The classes
- Throws:
IOException
-
getKonto
Liefert ein Konto zu den angegeben ID.- Parameters:
ktoId- die Konto-ID.- Returns:
- das Konto oder NULL.
-
getLastUmsatzDate
Liefert das Datum, ab wann die Umsätze geladen werden sollen. Das ist entweder das Datum der letzten regulären Buchung (vorgemerkte werden ignoriert) oder das angegebene Startdatum. Ist das Startdatum NULL, wird es auf den 01.01.2000 gesetzt. Zurückgegeben wird dann das jünger Datum.- Parameters:
konto- das KontostartDate- das StartDatum als Calendar-Objekt- Returns:
- Das Abrufdatum, das benutzt werden soll.
-
getYesNoStringFromBoolean
Returns the String object "JA" or "NEIN" depending on the given boolean value.- Parameters:
yesNo- boolean value to convert- Returns:
- the string representation of the specified
boolean
-
ibanFormater
Fügt einer IBAN ein Leerzeichen an jeder 4 Stelle hinzu.- Parameters:
iban- IBAN mit oder ohne Leerzeichen- Returns:
- IBAN mit Leerzeichen
-
loadUmsatz
public static void loadUmsatz(de.willuhn.jameica.hbci.rmi.Umsatz umsatz, String umsatzString) throws RemoteException Läd einen Umsatz-Beschreibungstext in einen Umsatz. Berücksichtigt dabei die max. Längen für die Zweck- und Zweck2-Felder und teilt die Beschreibung ggf. auf.- Parameters:
umsatz- das Hibicus Umsatz ObjektumsatzString- die Umsatzbeschreibung- Throws:
RemoteException
-
localDateToDate
-
maskCardNummer
Maskiert eine Karten-Nummer und zeigt nur die letzten 4 Ziffern- Parameters:
kartenNummer-- Returns:
- die maskierte Kartennummer
-
notifyUsers
Display a message to the users.- Parameters:
message- the message to display- See Also:
-
ApplicationCallback.notifyUser(String)
-
nowMinusDays
Returns theDatewith the given offset in the past- Parameters:
days-- Returns:
-
parseOrNull
Parse a date string with the given parser and either return the parsed date or NULL. No exception is thrown.- Parameters:
dateFormatter- the formatter to usevalue- the date string to parse- Returns:
- either the
Dateor null
-
removeEOL
Entfernt einen Zeilenumbruch am Ende einer Zeile. Der Zeilenumbruch kann Unix, MAC oder Windows format haben.- Parameters:
line- die Zeile- Returns:
- die Zeile ohne Zeilenumbruch
-
removePdfMeta
public static void removePdfMeta(de.willuhn.jameica.hbci.rmi.Konto account) Removes deprecated Kontoauszugs-PDF META information from an account. The method ignores all errors.- Parameters:
account- The account from which the META data should be removed
-
replaceUmlauts
Ersetzt alle deutschen Umlaute mit den deutschen Entsprechungen.- Parameters:
text- der original Text- Returns:
- Text mit umgewandelten Umlauten
-
roundDoubleToBigDecimal
Rundet auf die angegebene Anzahl Nachkommastellen- Parameters:
number- die Zahldigits- die Anzahl an Nachkommastellen- Returns:
- die gerundete Zahl as BigDecimal
-
roundNumber
public static double roundNumber(double number, int digits) Rundet auf die angegebene Anzahl Nachkommastellen- Parameters:
number- die Zahldigits- die Anzahl an Nachkommastellen- Returns:
- die gerundete Zahl
-
setProxyCfg
Setzt die Proxy-Einstellungen- Parameters:
webClient- der WebClienturl- die URL für den ein Proxy benötigt wird
-
waitIgnoreThreadInterrupts
public static void waitIgnoreThreadInterrupts(long millis) Waits for the given but doesn't handle a InterruptedException. So use with care!- Parameters:
millis-
-