Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Problem with dateItem.setUseMask

    I have a dateItem working fine with a European Short Date format: dd/MM/yy. and dateItem.setUseTextField(true). But if I set dateItem.setUseMask(true) the mask prevents the first digit of the day to be higher than 2.

    For example, I can enter 19/05/2010 w/o a problem, but I cannot enter 20/05/2010. If I select the same date (20/05/2010) from the calendar popup the value that is shown is "0/05/2010".

    Here is how I set the Date Format in my Entry Class
    Code:
    	// Set Default Formatting for Date Fields
    		DateUtil
    				.setShortDateDisplayFormat(DateDisplayFormat.TOEUROPEANSHORTDATE);
    
    		DateUtil.setDateInputFormatter(new DateInputFormatter() {
    			@Override
    			public Date parse(String dateString) {
    				try {
    					final DateTimeFormat dateFormatter = DateTimeFormat
    							.getFormat("dd/MM/yy");
    					Date date = dateFormatter.parse(dateString);
    					return date;
    
    				} catch (Exception e) {
    					return null;
    				}
    			}
    		});
    And here is how I set the DateItem
    Code:
    		dateProcess.setTitle("Fecha Proceso");
    		dateProcess.setUseTextField(true);
    		dateProcess.setUseMask(true);
    		dateProcess.setRequired(true);
    		dateProcess.setEnforceDate(true);
    - Thanks

    #2
    Add:
    Code:
    dateProcess.setInputFormat("DMY");

    Comment


      #3
      It works

      Thanks a lot, it works great.

      I am a bit confused of the need to specify different formats in different places to set the date format...and having to specify it widget by widget ! But in the end it works.

      Thanks again.

      Comment


        #4
        I agree and we'll have to look at this.

        Comment


          #5
          Hi

          I am using the nigthly build 2010-07-15 and I am having the same problem.

          the
          Code:
          .setInputFormat("DMY");
          does not help me here.

          There were any changes since this solution was posted?

          Comment


            #6
            I'm not aware of changes. What does "does not help me here" mean? Can you psot a standalone test case?

            Comment


              #7
              I made a cleaner example and it works. I am probably missing something.
              Thanks

              Comment

              Working...
              X