Package de.frankmuenster.mahoe.utils
Class Utils
- java.lang.Object
-
- de.frankmuenster.mahoe.utils.Utils
-
public final class Utils extends java.lang.Object
Utility-Klasse- Author:
- Frank Münster
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.ThreadLocal<java.text.DecimalFormat>
DECIMAL_FORMAT
Dezimal-Format mit genau 2 Nachkommastellenstatic double
DOUBLE_TREAT_AS_EQUAL
The difference below which doubles should be treated as equal numbersstatic java.lang.String
TEXT_JA
Textual boolean truestatic java.lang.String
TEXT_NEIN
Textual boolean false
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String
convertDoubleToString(java.lang.Double doubleValue)
Formatiert einen Double-Wert in einen String mit genau 2 Nachkommastellen.static java.lang.String
convertLocalDateTimeToString(java.time.LocalDateTime dateTime, java.lang.String format)
LocalDateTime to String converterstatic java.lang.String
convertLocalDateToString(java.time.LocalDate date)
LocalDate to String converter.static java.lang.String
convertLocalDateToString(java.time.LocalDate date, java.lang.String format)
LocalDate to String converterstatic java.math.BigDecimal
convertStringToBigDecimal(java.lang.String doubleString)
Remove EUR, EUR sign and thousand separator from given double string.static java.lang.Double
convertStringToDouble(java.lang.String doubleString)
Remove EUR and tausend separator from given double string.static java.util.Date
convertTextToDate(java.lang.String text, java.lang.String format)
Text to Date converterstatic java.time.LocalDate
convertTextToLocalDate(java.lang.String text, java.lang.String format)
String to LocalDate converterstatic java.time.LocalDate
dateToLocalDate(java.util.Date date)
Converts aDate
into aLocalDate
based on the default ZoneIdstatic boolean
getBooleanFromYesNoString(java.lang.String yesNo)
Returns "true
" in case the String is "JA", "false
" else.static java.lang.Class<?>[]
getClasses(java.lang.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
getKonto(java.lang.String ktoId)
Liefert ein Konto zu den angegeben ID.static java.util.Date
getLastUmsatzDate(de.willuhn.jameica.hbci.rmi.Konto konto, java.util.Calendar startDate)
Liefert das Datum, ab wann die Umsätze geladen werden sollen.static java.lang.String
getYesNoStringFromBoolean(boolean yesNo)
Returns the String object "JA" or "NEIN" depending on the given boolean value.static java.lang.String
ibanFormater(java.lang.String iban)
Fügt einer IBAN ein Leerzeichen an jeder 4 Stelle hinzu.static void
loadUmsatz(de.willuhn.jameica.hbci.rmi.Umsatz umsatz, java.lang.String umsatzString)
Läd einen Umsatz-Beschreibungstext in einen Umsatz.static java.util.Date
localDateToDate(java.time.LocalDate localDate)
Converts aLocalDate
into aDate
based on the default ZoneIdstatic java.lang.String
maskCardNummer(java.lang.String kartenNummer)
Maskiert eine Karten-Nummer und zeigt nur die letzten 4 Ziffernstatic void
notifyUsers(java.lang.String message)
Display a message to the users.static java.util.Date
nowMinusDays(int days)
Returns theDate
with the given offset in the paststatic java.util.Date
parseOrNull(java.text.DateFormat dateFormatter, java.lang.String value)
Parse a date string with the given parser and either return the parsed date or NULL.static java.lang.String
removeEOL(java.lang.String line)
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 java.lang.String
replaceUmlauts(java.lang.String text)
Ersetzt alle deutschen Umlaute mit den deutschen Entsprechungen.static java.math.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(com.gargoylesoftware.htmlunit.WebClient webClient, java.lang.String url)
Setzt die Proxy-Einstellungenstatic void
waitIgnoreThreadInterrupts(long millis)
Waits for the given but doesn't handle a InterruptedException.
-
-
-
Field Detail
-
DECIMAL_FORMAT
public static final java.lang.ThreadLocal<java.text.DecimalFormat> DECIMAL_FORMAT
Dezimal-Format mit genau 2 Nachkommastellen
-
DOUBLE_TREAT_AS_EQUAL
public static final double DOUBLE_TREAT_AS_EQUAL
The difference below which doubles should be treated as equal numbers- See Also:
- Constant Field Values
-
TEXT_JA
public static final java.lang.String TEXT_JA
Textual boolean true- See Also:
- Constant Field Values
-
TEXT_NEIN
public static final java.lang.String TEXT_NEIN
Textual boolean false- See Also:
- Constant Field Values
-
-
Method Detail
-
convertDoubleToString
public static java.lang.String convertDoubleToString(java.lang.Double doubleValue)
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 java.lang.String convertLocalDateTimeToString(java.time.LocalDateTime dateTime, java.lang.String format) throws java.time.format.DateTimeParseException
LocalDateTime to String converter- Parameters:
dateTime
-format
-- Throws:
java.text.ParseException
java.time.format.DateTimeParseException
-
convertLocalDateToString
public static java.lang.String convertLocalDateToString(java.time.LocalDate date)
LocalDate to String converter. The default format dd.MM.yyyy will be used.- Parameters:
date
- the date to convert- Throws:
java.text.ParseException
-
convertLocalDateToString
public static java.lang.String convertLocalDateToString(java.time.LocalDate date, java.lang.String format) throws java.time.format.DateTimeParseException
LocalDate to String converter- Parameters:
date
-format
-- Throws:
java.text.ParseException
java.time.format.DateTimeParseException
-
convertStringToBigDecimal
public static java.math.BigDecimal convertStringToBigDecimal(java.lang.String doubleString)
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
public static java.lang.Double convertStringToDouble(java.lang.String doubleString)
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
public static java.util.Date convertTextToDate(java.lang.String text, java.lang.String format) throws java.text.ParseException
Text to Date converter- Throws:
java.text.ParseException
-
convertTextToLocalDate
public static java.time.LocalDate convertTextToLocalDate(java.lang.String text, java.lang.String format) throws java.time.format.DateTimeParseException
String to LocalDate converter- Throws:
java.text.ParseException
java.time.format.DateTimeParseException
-
dateToLocalDate
public static java.time.LocalDate dateToLocalDate(java.util.Date date)
Converts aDate
into aLocalDate
based on the default ZoneId- Parameters:
date
- theDate
to convert- Returns:
- the converted
LocalDate
-
getBooleanFromYesNoString
public static boolean getBooleanFromYesNoString(java.lang.String yesNo)
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
public static java.lang.Class<?>[] getClasses(java.lang.String packageName) throws java.io.IOException
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:
java.io.IOException
-
getKonto
public static de.willuhn.jameica.hbci.rmi.Konto getKonto(java.lang.String ktoId)
Liefert ein Konto zu den angegeben ID.- Parameters:
ktoId
- die Konto-ID.- Returns:
- das Konto oder NULL.
-
getLastUmsatzDate
public static java.util.Date getLastUmsatzDate(de.willuhn.jameica.hbci.rmi.Konto konto, java.util.Calendar startDate)
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
public static java.lang.String getYesNoStringFromBoolean(boolean yesNo)
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
public static java.lang.String ibanFormater(java.lang.String iban)
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, java.lang.String umsatzString) throws java.rmi.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:
java.rmi.RemoteException
-
localDateToDate
public static java.util.Date localDateToDate(java.time.LocalDate localDate)
Converts aLocalDate
into aDate
based on the default ZoneId- Parameters:
localDate
- theLocalDate
to convert- Returns:
- the converted
Date
-
maskCardNummer
public static java.lang.String maskCardNummer(java.lang.String kartenNummer)
Maskiert eine Karten-Nummer und zeigt nur die letzten 4 Ziffern- Parameters:
kartenNummer
-- Returns:
- die maskierte Kartennummer
-
notifyUsers
public static void notifyUsers(java.lang.String message)
Display a message to the users.- Parameters:
message
- the message to display- See Also:
ApplicationCallback.notifyUser(String)
-
nowMinusDays
public static java.util.Date nowMinusDays(int days)
Returns theDate
with the given offset in the past- Parameters:
days
-- Returns:
-
parseOrNull
public static java.util.Date parseOrNull(java.text.DateFormat dateFormatter, java.lang.String value)
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
public static java.lang.String removeEOL(java.lang.String line)
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
public static java.lang.String replaceUmlauts(java.lang.String text)
Ersetzt alle deutschen Umlaute mit den deutschen Entsprechungen.- Parameters:
text
- der original Text- Returns:
- Text mit umgewandelten Umlauten
-
roundDoubleToBigDecimal
public static java.math.BigDecimal roundDoubleToBigDecimal(double number, int digits)
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
public static void setProxyCfg(com.gargoylesoftware.htmlunit.WebClient webClient, java.lang.String url)
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
-
-
-