Jump to content
We've recently updated our Privacy Statement, available here ×
  • Ad Hoc filter invalid date or timestamp


    Jim W
    • Features: Ad Hoc Version: v7.2 Product: JasperReports® Server

    Problem Description:

    When creating an Ad Hoc date or timestamp filter in the Ad Hoc designer, you enter a date or timestamp, you see the following error:

        ! Invalid timestamp. Use relative date keywords or correct timestamp format.

        ! Invalid date. Use relative date keywords or correct date format.

    Either you had entered a date in incorrect format, or there is an error in the configuration.  We are addressing the latter possibility here.


    Solution:

    If you had changed the configuration file jasperserver_config.properties files to support a certain date or timestamp format and it is not behaving as expecting.  You might have made a mistake in the configuration.  Note that in the configurations above the comments block, y represents 1 digit.  After the comments, y represents 2 digits.  Check and be sure that you have entered the correct number of y's for the year format.  For example,

    For a 2-digit year case:

    date.format=MM/dd/yy
    datetime.format=MM/dd/yy HH:mm:ss
    time.format=HH:mm:ss
    
    calendar.date.format=mm/dd/y
    calendar.datetime.format=mm/dd/y HH:mm:ss
    calendar.time.format=HH:mm:ss
    
    validation.date.pattern=/^\\d{2}\/\\d{2}\/\\d{2}$/
    validation.datetime.pattern=/^\\d{2}\/\\d{2}\/\\d{2}\\s\\d{2}:\\d{2}:\\d{2}$/
    validation.time.pattern=/^\\d{2}:\\d{2}:\\d{2}$/
    
    

    For a 4-digit year case: 

    date.format=MM/dd/yyyy
    datetime.format=MM/dd/yyyy HH:mm:ss
    time.format=HH:mm:ss
    
    calendar.date.format=mm/dd/yy
    calendar.datetime.format=mm/dd/yy HH:mm:ss
    calendar.time.format=HH:mm:ss
    
    validation.date.pattern=/^\\d{2}\/\\d{2}\/\\d{4}$/
    validation.datetime.pattern=/^\\d{2}\/\\d{2}\/\\d{4}\\s\\d{2}:\\d{2}:\\d{2}$/
    validation.time.pattern=/^\\d{2}:\\d{2}:\\d{2}$/

     


    User Feedback

    Recommended Comments

    jasperserver_config.properties:

    date.format=MM/dd/yyyy
    datetime.format=MM/dd/yyyy HH:mm:ss
    time.format=HH:mm:ss
     

    calendar.date.format=mm/dd/yy
    calendar.datetime.format=mm/dd/yy HH:mm:ss
    calendar.time.format=HH:mm:ss

     

    calendar.datetime.separator=u0020
     

    validation.date.pattern=/^d{2}/d{2}/d{4}$/
    validation.datetime.pattern=/^d{2}/d{2}/d{4}sd{2}:d{2}:d{2}$/
    validation.time.pattern=/^d{2}:d{2}:d{2}$/
     

    repository.date.format=M/d/yyyy
    repository.current.year.date.format=MMMMM d
    repository.datetime.format=M/d/yyyy hh:mmaaa
    repository.time.format=hh:mmaaa

    report.scheduling.output.format.1=pdf
    report.scheduling.output.format.2=html
    report.scheduling.output.format.3=xls
    report.scheduling.output.format.4=rtf
    report.scheduling.output.format.5=csv
    report.scheduling.output.format.6=odt
    report.scheduling.output.format.7=txt
    report.scheduling.output.format.8=docx
    report.scheduling.output.format.9=ods
    report.scheduling.output.format.10=xlsx
    report.scheduling.output.format.14=pptx
     

    input.password.substitution=~value~subst~

    client.delimiters.thousands = ,
    client.delimiters.decimal = .
    client.currency.symbol = $

    ====================================================

     

     

    See screenshot........

     

    /sites/default/files/user_uploads/tchen/screenshot_6053.png

    Link to comment
    Share on other sites

    The format value for dateTimeFormatValidationRule does not macht the configured values

    1. dataType: {type: "datetime", strictMax: false, minValue: "2013-03-01T00:00:00", strictMin: true}
    2. description: ""
    3. id: "startdatetime"
    4. label: "von"
    5. mandatory: true
    6. masterDependencies: []
    7. readOnly: false
    8. slaveDependencies: ["shopid", "employeeid"]
    9. type: "singleValueDatetime"
    10. uri: "repo:/Input_Control/Date_and_Time/startdatetime"
    11. validationRules: [,…]
      1. 0: {mandatoryValidationRule: {errorMessage: "Dieses Feld ist erforderlich. Sie müssen Daten eingeben."}}
      2. 1: {,…}
        1. dateTimeFormatValidationRule: {errorMessage: "Geben Sie einen gültigen Datums-/Uhrzeitwert an.", format: "yyyy-MM-dd'T'HH:mm:ss"}
          1. errorMessage: "Geben Sie einen gültigen Datums-/Uhrzeitwert an."
          2. format: "yyyy-MM-dd'T'HH:mm:ss"
    12. visible: true

     

    configured value from file WEB-INF/bundles/jasperserver_config_de.properties: datetime.format=dd.MM.yyyy HH:mm:ss

     

    i found out why this is not working because the wrong values are hardcoded in source

    import com.jaspersoft.jasperserver.inputcontrols.util.DefaultCalendarFormatProvider;

    /**
     * <p></p>
     *
     * @author yaroslav.kovalchyk
     * @version $Id$
     */
    public class IsoCalendarFormatProvider extends DefaultCalendarFormatProvider {
        @Override
        protected String getDatetimeFormatPattern() {
            return "yyyy-MM-dd'T'HH:mm:ss";
        }

        @Override
        protected String getTimeFormatPattern() {
            return "HH:mm:ss";
        }

        @Override
        protected String getDateFormatPattern() {
            return "yyyy-MM-dd";
        }
    }
     

    as long as the validator is not using the configured values the validation will not work

    Link to comment
    Share on other sites



    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

×
×
  • Create New...