Class DatatypeFormatter

java.lang.Object
io.jmix.core.metamodel.datatype.DatatypeFormatter

@Component("core_DatatypeFormatter") public class DatatypeFormatter extends Object
Convenience bean for locale-dependent conversion of some widely used data types to and from strings.

For locale-independent conversion use Datatype methods directly.

  • Field Details

  • Constructor Details

    • DatatypeFormatter

      public DatatypeFormatter()
  • Method Details

    • formatDate

      public String formatDate(@Nullable Date value)
      Format Date (date without time) using dateFormat string specified in the main message group.
      Returns:
      string representation or empty string if the value is null
    • formatTime

      public String formatTime(@Nullable Date value)
      Format Date (time without date) using timeFormat string specified in the main message group.
      Returns:
      string representation or empty string if the value is null
    • formatDateTime

      public String formatDateTime(@Nullable Date value)
      Format Date (date and time) using dateTimeFormat string specified in the main message group.

      Takes into account time zone if it is set for the current user session.

      Returns:
      string representation or empty string if the value is null
    • formatLocalDate

      public String formatLocalDate(@Nullable LocalDate value)
      Format LocalDate (date without time and without a time-zone) using dateFormat string specified in the main message group.
      Returns:
      string representation or empty string if the value is null
    • formatLocalDateTime

      public String formatLocalDateTime(@Nullable LocalDateTime value)
      Format LocalDateTime (date and time without a time-zone) using dateTimeFormat string specified in the main message group.
      Returns:
      string representation or empty string if the value is null
    • formatLocalTime

      public String formatLocalTime(@Nullable LocalTime value)
      Format LocalTime (time without date and without a time-zone) using timeFormat string specified in the main message group.
      Returns:
      string representation or empty string if the value is null
    • formatOffsetDateTime

      public String formatOffsetDateTime(@Nullable OffsetDateTime value)
      Format OffsetDateTime (date and time with an offset from UTC/Greenwich) using offsetDateTimeFormat string specified in the main message group.
      Returns:
      string representation or empty string if the value is null
    • formatOffsetTime

      public String formatOffsetTime(@Nullable OffsetTime value)
      Format OffsetTime (time with an offset from UTC/Greenwich) using offsetTimeFormat string specified in the main message group.
      Returns:
      string representation or empty string if the value is null
    • formatDouble

      public String formatDouble(@Nullable Double value)
      Format Double using doubleFormat string specified in the main message group.
      Returns:
      string representation or empty string if the value is null
    • formatBigDecimal

      public String formatBigDecimal(@Nullable BigDecimal value)
      Format BigDecimal using decimalFormat string specified in the main message group.
      Returns:
      string representation or empty string if the value is null
    • formatBoolean

      public String formatBoolean(@Nullable Boolean value)
      Format Boolean using trueString and falseString strings specified in the main message group.
      Returns:
      string representation or empty string if the value is null
    • formatInteger

      public String formatInteger(@Nullable Integer value)
      Format Integer using integerFormat string specified in the main message group.
      Returns:
      string representation or empty string if the value is null
    • formatLong

      public String formatLong(@Nullable Long value)
      Format Long using integerFormat string specified in the main message group.
      Returns:
      string representation or empty string if the value is null
    • parseDate

      @Nullable public Date parseDate(String str) throws ParseException
      Parse Date (date without time) using dateFormat string specified in the main message group.
      Returns:
      Date value or null if a blank string is provided
      Throws:
      ParseException
    • parseTime

      @Nullable public Date parseTime(String str) throws ParseException
      Parse Date (time without date) using timeFormat string specified in the main message group.
      Returns:
      Date value or null if a blank string is provided
      Throws:
      ParseException
    • parseDateTime

      @Nullable public Date parseDateTime(String str) throws ParseException
      Parse Date (date and time) using dateTimeFormat string specified in the main message group.

      Takes into account time zone if it is set for the current user session.

      Returns:
      Date value or null if a blank string is provided
      Throws:
      ParseException
    • parseLocalDate

      @Nullable public LocalDate parseLocalDate(String str) throws ParseException
      Parse LocalDate (date without time and without a time-zone) using dateFormat string specified in the main message group.
      Returns:
      LocalDate value or null if a blank string is provided
      Throws:
      ParseException
    • parseLocalTime

      @Nullable public LocalTime parseLocalTime(String str) throws ParseException
      Parse LocalTime (time without date and without a time-zone) using timeFormat string specified in the main message group.
      Returns:
      LocalTime value or null if a blank string is provided
      Throws:
      ParseException
    • parseLocalDateTime

      @Nullable public LocalDateTime parseLocalDateTime(String str) throws ParseException
      Parse LocalDateTime (date and time without a time-zone) using dateTimeFormat string specified in the main message group.
      Returns:
      LocalDateTime value or null if a blank string is provided
      Throws:
      ParseException
    • parseOffsetDateTime

      @Nullable public OffsetDateTime parseOffsetDateTime(String str) throws ParseException
      Parse OffsetDateTime (date and time with an offset from UTC/Greenwich) using offsetDateTimeFormat string specified in the main message group.
      Returns:
      OffsetDateTime value or null if a blank string is provided
      Throws:
      ParseException
    • parseOffsetTime

      @Nullable public OffsetTime parseOffsetTime(String str) throws ParseException
      Parse OffsetTime (time without date and with an offset from UTC/Greenwich) using offsetTimeFormat string specified in the main message group.
      Returns:
      OffsetTime value or null if a blank string is provided
      Throws:
      ParseException
    • parseDouble

      @Nullable public Double parseDouble(String str) throws ParseException
      Parse Double using doubleFormat string specified in the main message group.
      Returns:
      Double value or null if a blank string is provided
      Throws:
      ParseException
    • parseBigDecimal

      @Nullable public BigDecimal parseBigDecimal(String str) throws ParseException
      Parse BigDecimal using decimalFormat string specified in the main message group.
      Returns:
      BigDecimal value or null if a blank string is provided
      Throws:
      ParseException
    • parseBoolean

      @Nullable public Boolean parseBoolean(String str) throws ParseException
      Parse Boolean using trueString and falseString strings specified in the main message group.
      Returns:
      Boolean value or null if a blank string is provided
      Throws:
      ParseException
    • parseInteger

      @Nullable public Integer parseInteger(String str) throws ParseException
      Parse Integer using integerFormat string specified in the main message group.
      Returns:
      Integer value or null if a blank string is provided
      Throws:
      ParseException
    • parseLong

      @Nullable public Long parseLong(String str) throws ParseException
      Parse Long using integerFormat string specified in the main message group.
      Returns:
      Long value or null if a blank string is provided
      Throws:
      ParseException