Class LocalDateToDateConverter

  • All Implemented Interfaces:
    Converter<java.time.LocalDate,​java.util.Date>, java.io.Serializable

    public class LocalDateToDateConverter
    extends java.lang.Object
    implements Converter<java.time.LocalDate,​java.util.Date>
    A converter that converts between LocalDate and Date. This is used when a DateField or InlineDateField is bound to a Date property.
    Since:
    8.0
    Author:
    Vaadin Ltd
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      LocalDateToDateConverter()
      Creates a new converter using the system's default time zone.
      LocalDateToDateConverter​(java.time.ZoneId zoneId)
      Creates a new converter using the given time zone.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Result<java.util.Date> convertToModel​(java.time.LocalDate localDate, ValueContext context)
      Converts the given value from model type to presentation type.
      java.time.LocalDate convertToPresentation​(java.util.Date date, ValueContext context)
      Converts the given value from presentation type to model type.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • LocalDateToDateConverter

        public LocalDateToDateConverter​(java.time.ZoneId zoneId)
        Creates a new converter using the given time zone.
        Parameters:
        zoneId - the time zone id to use, not null
      • LocalDateToDateConverter

        public LocalDateToDateConverter()
        Creates a new converter using the system's default time zone.
        See Also:
        ZoneId.systemDefault()
    • Method Detail

      • convertToModel

        public Result<java.util.Date> convertToModel​(java.time.LocalDate localDate,
                                                     ValueContext context)
        Description copied from interface: Converter
        Converts the given value from model type to presentation type.

        A converter can optionally use locale to do the conversion.

        Specified by:
        convertToModel in interface Converter<java.time.LocalDate,​java.util.Date>
        Parameters:
        localDate - The value to convert. Can be null
        context - The value context for the conversion.
        Returns:
        The converted value compatible with the source type
      • convertToPresentation

        public java.time.LocalDate convertToPresentation​(java.util.Date date,
                                                         ValueContext context)
        Description copied from interface: Converter
        Converts the given value from presentation type to model type.

        A converter can optionally use locale to do the conversion.

        Specified by:
        convertToPresentation in interface Converter<java.time.LocalDate,​java.util.Date>
        Parameters:
        date - The value to convert. Can be null
        context - The value context for the conversion.
        Returns:
        The converted value compatible with the source type