Class Utils

java.lang.Object
de.frankmuenster.mahoe.utils.Utils

public final class Utils extends Object
Utility-Klasse
Author:
Frank Münster
  • Field Details

    • DECIMAL_FORMAT

      public static final ThreadLocal<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:
    • TEXT_JA

      public static final String TEXT_JA
      Textual boolean true
      See Also:
    • TEXT_NEIN

      public static final String TEXT_NEIN
      Textual boolean false
      See Also:
  • Method Details

    • convertDoubleToString

      public static String convertDoubleToString(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 String convertLocalDateTimeToString(LocalDateTime dateTime, String format) throws DateTimeParseException
      LocalDateTime to String converter
      Parameters:
      dateTime -
      format -
      Throws:
      ParseException
      DateTimeParseException
    • convertLocalDateToString

      public static String convertLocalDateToString(LocalDate date)
      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

      public static BigDecimal convertStringToBigDecimal(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 Double convertStringToDouble(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 Date convertTextToDate(String text, String format) throws ParseException
      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

      public static LocalDate dateToLocalDate(Date date)
      Converts a Date into a LocalDate based on the default ZoneId
      Parameters:
      date - the Date to convert
      Returns:
      the converted LocalDate
    • getBooleanFromYesNoString

      public static boolean getBooleanFromYesNoString(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 Class<?>[] getClasses(String packageName) throws 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:
      IOException
    • getKonto

      public static de.willuhn.jameica.hbci.rmi.Konto getKonto(String ktoId)
      Liefert ein Konto zu den angegeben ID.
      Parameters:
      ktoId - die Konto-ID.
      Returns:
      das Konto oder NULL.
    • getLastUmsatzDate

      public static Date getLastUmsatzDate(de.willuhn.jameica.hbci.rmi.Konto konto, 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 Konto
      startDate - das StartDatum als Calendar-Objekt
      Returns:
      Das Abrufdatum, das benutzt werden soll.
    • getYesNoStringFromBoolean

      public static 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 String ibanFormater(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, 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 Objekt
      umsatzString - die Umsatzbeschreibung
      Throws:
      RemoteException
    • localDateToDate

      public static Date localDateToDate(LocalDate localDate)
      Converts a LocalDate into a Date based on the default ZoneId
      Parameters:
      localDate - the LocalDate to convert
      Returns:
      the converted Date
    • maskCardNummer

      public static String maskCardNummer(String kartenNummer)
      Maskiert eine Karten-Nummer und zeigt nur die letzten 4 Ziffern
      Parameters:
      kartenNummer -
      Returns:
      die maskierte Kartennummer
    • notifyUsers

      public static void notifyUsers(String message)
      Display a message to the users.
      Parameters:
      message - the message to display
      See Also:
      • ApplicationCallback.notifyUser(String)
    • nowMinusDays

      public static Date nowMinusDays(int days)
      Returns the Date with the given offset in the past
      Parameters:
      days -
      Returns:
    • parseOrNull

      public static Date parseOrNull(DateFormat dateFormatter, 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 use
      value - the date string to parse
      Returns:
      either the Date or null
    • removeEOL

      public static String removeEOL(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 String replaceUmlauts(String text)
      Ersetzt alle deutschen Umlaute mit den deutschen Entsprechungen.
      Parameters:
      text - der original Text
      Returns:
      Text mit umgewandelten Umlauten
    • roundDoubleToBigDecimal

      public static BigDecimal roundDoubleToBigDecimal(double number, int digits)
      Rundet auf die angegebene Anzahl Nachkommastellen
      Parameters:
      number - die Zahl
      digits - 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 Zahl
      digits - die Anzahl an Nachkommastellen
      Returns:
      die gerundete Zahl
    • setProxyCfg

      public static void setProxyCfg(org.htmlunit.WebClient webClient, String url)
      Setzt die Proxy-Einstellungen
      Parameters:
      webClient - der WebClient
      url - 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 -