Class Parser

java.lang.Object
de.eldoria.eldoutilities.utils.Parser

public final class Parser extends Object
This class contains methods to parse strings to primitve types and other things.
Since:
1.0.0
  • Method Details

    • parseInt

      public static Optional<Integer> parseInt(String s)
      Parse a string to a int.
      Parameters:
      s - string to parse
      Returns:
      optional integer with integer when the parsing was successful.
    • parseDouble

      public static Optional<Double> parseDouble(String s)
      Parse a string to a double.
      Parameters:
      s - string to parse
      Returns:
      optional double with double when the parsing was successful.
    • parseBoolean

      public static Optional<Boolean> parseBoolean(String s)
      Parse a string to a boolean
      Parameters:
      s - string to parse
      Returns:
      optional boolean with boolean when the parsing was successful.
    • parseBoolean

      public static Optional<Boolean> parseBoolean(String s, String trueValue, String falseValue)
      Parse a string to a boolean
      Parameters:
      s - string to parse
      trueValue - true value as string
      falseValue - false value as string
      Returns:
      optional boolean with boolean when the parsing was successful.
    • parseTimeToTicks

      public static OptionalInt parseTimeToTicks(String s)
      Parses a time in format H24:mm to ticks.
      Parameters:
      s - string to parse
      Returns:
      time as ticks or null if value could not be parsed.
    • parseTicksToTime

      public static String parseTicksToTime(long ticks)
      Parses ticks to a time with format H24:mm.
      Parameters:
      ticks - ticks to parse
      Returns:
      ticks as time
    • parseLong

      public static <T> Optional<Long> parseLong(String value)