Class Helper

java.lang.Object
eu.hansolo.toolbox.Helper

public class Helper extends Object
  • Method Details

    • clamp

      public static final <T extends Number> T clamp(T min, T max, T value)
    • clamp

      public static final int clamp(int min, int max, int value)
    • clamp

      public static final long clamp(long min, long max, long value)
    • clamp

      public static final double clamp(double min, double max, double value)
    • clamp

      public static final Instant clamp(Instant min, Instant max, Instant value)
    • clamp

      public static final LocalDateTime clamp(LocalDateTime min, LocalDateTime max, LocalDateTime value)
    • clamp

      public static final LocalDate clamp(LocalDate min, LocalDate max, LocalDate value)
    • clampMin

      public static final double clampMin(double min, double value)
    • clampMax

      public static final double clampMax(double max, double value)
    • almostEqual

      public static final boolean almostEqual(double value1, double value2, double epsilon)
    • round

      public static final double round(double value, int precision)
    • roundTo

      public static final double roundTo(double value, double target)
    • roundToHalf

      public static final double roundToHalf(double value)
    • roundDoubleToInt

      public static final int roundDoubleToInt(double value)
    • equals

      public static final boolean equals(double a, double b)
    • biggerThan

      public static final boolean biggerThan(double a, double b)
    • lessThan

      public static final boolean lessThan(double a, double b)
    • isPositiveInteger

      public static final boolean isPositiveInteger(String text)
    • trimPrefix

      public static final String trimPrefix(String text, String prefix)
    • getDateFormat

      public static final DateTimeFormatter getDateFormat(Locale locale)
    • getLocalizedDateFormat

      public static final DateTimeFormatter getLocalizedDateFormat(Locale locale)
    • normalize

      public static final String normalize(String text)
    • getDegrees

      public static final int getDegrees(double decDeg)
    • getMinutes

      public static final int getMinutes(double decDeg)
    • getSeconds

      public static final double getSeconds(double decDeg)
    • getDecimalDeg

      public static final double getDecimalDeg(int degrees, int minutes, double seconds)
    • not

      public static final <T> Predicate<T> not(Predicate<T> predicate)
    • lastN

      public static <T> Collector<T,?,List<T>> lastN(int n)
    • getDoubleFromText

      public static final double getDoubleFromText(String text)
    • getIntFromText

      public static final int getIntFromText(String text)
    • getHexColorFromString

      public static final String getHexColorFromString(String text)
    • readFromInputStream

      public static String readFromInputStream(InputStream inputStream) throws IOException
      Throws:
      IOException
    • readTextFile

      public static final String readTextFile(String filename)
    • saveTxtFile

      public static final void saveTxtFile(String filename, String text)
    • getFirstDayOfWeek

      public static final LocalDate getFirstDayOfWeek(int year, int weekNumber, Locale locale)
    • getEpochSecondsOfFirstDayOfWeek

      public static final long getEpochSecondsOfFirstDayOfWeek(int year, int weekNumber, Locale locale)
    • getLastDayOfWeek

      public static final LocalDate getLastDayOfWeek(int year, int weekNumber, Locale locale)
    • getEpochSecondsOfLastDayOfWeek

      public static final long getEpochSecondsOfLastDayOfWeek(int year, int weekNumber, Locale locale)
    • getWeekOfYear

      public static final int getWeekOfYear(ZonedDateTime zonedDateTime)
    • getWeekOfYeear

      public static final int getWeekOfYeear(Instant instant)
    • getWeekOfYear

      public static final int getWeekOfYear(Instant instant, ZoneId zoneId)
    • getWeekOfYear

      public static final int getWeekOfYear(LocalDateTime dateTime)
    • getWeekOfYear

      public static final int getWeekOfYear(LocalDate date)
    • getWeekOfYear

      public static final int getWeekOfYear(long epochSeconds)
    • getWeekOfYear

      public static final int getWeekOfYear(long epochSeconds, ZoneId zoneId)
    • shortenNumber

      public static final String shortenNumber(long value)
    • shortenNumber

      public static final String shortenNumber(long value, Locale locale)
    • getMaxValueInMap

      public static final <K, V extends Comparable<V>> V getMaxValueInMap(Map<K,V> map)
    • getKeyWithMaxValueInMap

      public static final <K, V extends Comparable<V>> K getKeyWithMaxValueInMap(Map<K,V> map)
    • secondsToHHMMString

      public static final String secondsToHHMMString(long seconds)
    • secondsToHHMMSS

      public static final long[] secondsToHHMMSS(long seconds)
    • getCRC32Checksum

      public static final long getCRC32Checksum(byte[] bytes)
    • getMD5

      public static final String getMD5(String text)
    • getMD5

      public static final String getMD5(byte[] bytes)
    • getMD5Bytes

      public static final byte[] getMD5Bytes(byte[] bytes)
    • getMD5ForFile

      public static final String getMD5ForFile(File file) throws Exception
      Throws:
      Exception
    • getSHA1

      public static final String getSHA1(String text)
    • getSHA1

      public static final String getSHA1(byte[] bytes)
    • getSHA1Bytes

      public static final byte[] getSHA1Bytes(byte[] bytes)
    • getSHA1ForFile

      public static final String getSHA1ForFile(File file) throws Exception
      Throws:
      Exception
    • getSHA256

      public static final String getSHA256(String text)
    • getSHA256

      public static final String getSHA256(byte[] bytes)
    • getSHA256Bytes

      public static final byte[] getSHA256Bytes(byte[] bytes)
    • getSHA256ForFile

      public static final String getSHA256ForFile(File file) throws Exception
      Throws:
      Exception
    • getSHA3_256

      public static final String getSHA3_256(String text)
    • getSHA3_256

      public static final String getSHA3_256(byte[] bytes)
    • getSHA3_256Bytes

      public static final byte[] getSHA3_256Bytes(byte[] bytes)
    • getSHA3_256ForFile

      public static final String getSHA3_256ForFile(File file) throws Exception
      Throws:
      Exception
    • bytesToHex

      public static final String bytesToHex(byte[] bytes)