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 double
The difference below which doubles should be treated as equal numbersstatic final String
Textual boolean truestatic final String
Textual boolean false -
Method Summary
Modifier and TypeMethodDescriptionstatic String
convertDoubleToString
(Double doubleValue) Formatiert einen Double-Wert in einen String mit genau 2 Nachkommastellen.static String
convertLocalDateTimeToString
(LocalDateTime dateTime, String format) LocalDateTime to String converterstatic String
LocalDate to String converter.static String
convertLocalDateToString
(LocalDate date, String format) LocalDate to String converterstatic BigDecimal
convertStringToBigDecimal
(String doubleString) Remove EUR, EUR sign and thousand separator from given double string.static Double
convertStringToDouble
(String doubleString) Remove EUR and tausend separator from given double string.static Date
convertTextToDate
(String text, String format) Text to Date converterstatic LocalDate
convertTextToLocalDate
(String text, String format) String to LocalDate converterstatic LocalDate
dateToLocalDate
(Date date) static boolean
getBooleanFromYesNoString
(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.Konto
Liefert ein Konto zu den angegeben ID.static Date
getLastUmsatzDate
(de.willuhn.jameica.hbci.rmi.Konto konto, Calendar startDate) Liefert das Datum, ab wann die Umsätze geladen werden sollen.static String
getYesNoStringFromBoolean
(boolean yesNo) Returns the String object "JA" or "NEIN" depending on the given boolean value.static String
ibanFormater
(String iban) Fügt einer IBAN ein Leerzeichen an jeder 4 Stelle hinzu.static void
loadUmsatz
(de.willuhn.jameica.hbci.rmi.Umsatz umsatz, String umsatzString) Läd einen Umsatz-Beschreibungstext in einen Umsatz.static Date
localDateToDate
(LocalDate localDate) static String
maskCardNummer
(String kartenNummer) Maskiert eine Karten-Nummer und zeigt nur die letzten 4 Ziffernstatic void
notifyUsers
(String message) Display a message to the users.static Date
nowMinusDays
(int days) Returns theDate
with the given offset in the paststatic Date
parseOrNull
(DateFormat dateFormatter, String value) Parse a date string with the given parser and either return the parsed date or NULL.static String
Entfernt einen Zeilenumbruch am Ende einer Zeile.static void
removePdfMeta
(de.willuhn.jameica.hbci.rmi.Konto account) Removes deprecated Kontoauszugs-PDF META information from an account.static String
replaceUmlauts
(String text) Ersetzt alle deutschen Umlaute mit den deutschen Entsprechungen.static BigDecimal
roundDoubleToBigDecimal
(double number, int digits) Rundet auf die angegebene Anzahl Nachkommastellenstatic double
roundNumber
(double number, int digits) Rundet auf die angegebene Anzahl Nachkommastellenstatic void
setProxyCfg
(org.htmlunit.WebClient webClient, String url) Setzt die Proxy-Einstellungenstatic void
waitIgnoreThreadInterrupts
(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:
ParseException
DateTimeParseException
-
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:
ParseException
DateTimeParseException
-
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:
ParseException
DateTimeParseException
-
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 theDate
with 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
Date
or 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
-
-