Class DateConverter

    • Constructor Detail

      • DateConverter

        public DateConverter​(boolean applyTimeZoneDifference)
        Construct.

        When applyTimeZoneDifference is true, the current time is applied on the parsed date, and the date will be corrected for the time zone difference between the server and the client. For instance, if I'm in Seattle and the server I'm working on is in Amsterdam, the server is 9 hours ahead. So, if I'm inputting say 12/24 at a couple of hours before midnight, at the server it is already 12/25. If this boolean is true, it will be transformed to 12/25, while the client sees 12/24.

        Parameters:
        applyTimeZoneDifference - whether to apply the difference in time zones between client and server
    • Method Detail

      • getApplyTimeZoneDifference

        public final boolean getApplyTimeZoneDifference()
        Gets whether to apply the time zone difference when interpreting dates.

        When true, the current time is applied on the parsed date, and the date will be corrected for the time zone difference between the server and the client. For instance, if I'm in Seattle and the server I'm working on is in Amsterdam, the server is 9 hours ahead. So, if I'm inputting say 12/24 at a couple of hours before midnight, at the server it is already 12/25. If this boolean is true, it will be transformed to 12/25, while the client sees 12/24.

        Returns:
        whether to apply the difference in time zones between client and server
      • getDatePattern

        public abstract String getDatePattern​(Locale locale)
        Parameters:
        locale - The locale used to convert the value
        Returns:
        Gets the pattern that is used for printing and parsing
      • getClientTimeZone

        protected TimeZone getClientTimeZone()
        Gets the client's time zone.
        Returns:
        The client's time zone or null
      • getFormat

        protected abstract org.joda.time.format.DateTimeFormatter getFormat​(Locale locale)
        Parameters:
        locale - The locale used to convert the value
        Returns:
        formatter The formatter for the current conversion
      • getTimeZone

        protected org.joda.time.DateTimeZone getTimeZone()
        Gets the server time zone. Override this method if you want to fix to a certain time zone, regardless of what actual time zone the server is in.
        Returns:
        The server time zone