Interface DurationFormat

All Known Implementing Classes:
FullWordEnglishDurationFormat, MediumLenghtRussianDurationFormat, MediumLengthEnglishDurationFormat, ShortEnglishDurationFormat, ShortRussianDurationFormat, StaticDurationFormat

public interface DurationFormat
  • Method Summary

    Modifier and Type
    Method
    Description
    @NotNull Duration
    deserialize(@NotNull String unitInput, @org.jetbrains.annotations.Range(from=0L, to=9223372036854775807L) long amountInput)
    Parses the given string into a duration unit.
    @NotNull String
    serialize(@NotNull DurationUnit unit, @org.jetbrains.annotations.Range(from=0L, to=9223372036854775807L) long amount)
    Formats the given duration into a string.
  • Method Details

    • serialize

      @Contract(value="_, _ -> new", pure=true) @NotNull @NotNull String serialize(@NotNull @NotNull DurationUnit unit, @org.jetbrains.annotations.Range(from=0L, to=9223372036854775807L) long amount)
      Formats the given duration into a string.

      For example, it can convert MINUTES and 5 to "5 minutes".

      Parameters:
      unit - duration unit
      amount - duration amount
      Returns:
      string representation of duration unit with specified amount
    • deserialize

      @Contract(value="_, _ -> new", pure=true) @NotNull @NotNull Duration deserialize(@NotNull @NotNull String unitInput, @org.jetbrains.annotations.Range(from=0L, to=9223372036854775807L) long amountInput) throws InvalidFormatException
      Parses the given string into a duration unit.

      For example, it can convert "5 minutes" to Duration.ofMinutes(5).

      Parameters:
      unitInput - input string which should contain only duration unit string representation
      amountInput - time amount
      Returns:
      parsed duration
      Throws:
      InvalidFormatException - if input string is not a valid duration unit