Announcement

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

    Bug in Date Format

    I am using dateItem field with setUseTextField(true);
    Now i want my date in a specific format , and for this purpose i have written following code.
    But the DateItem is not working correctly means the derise format is not getting set, it is changing to incorrect format automatically. I think this is a bug of smratGwt.
    Is anybody know how to fix this?


    Code:
    
    public static void setDateItemFormat(String dtFormat ){
    		DateUtil.setShortDateDisplayFormatter(
    				new DateDisplayFormatter() { 
    					public String format(Date date) { 
    						try {
    							if(date == null) return null; 
    							String 														DateTimeFormat dateFormatter = DateTimeFormat.getFormat(dtFormat); 
    							String format = dateFormatter.format(date); 
    							
    							return format;
    						} catch (Exception e) {
    
    							e.printStackTrace();
    							return null; 
    						} 
    					}
    
    					
    				});
    
    	}

    #2
    Make sure you setInputFormat() to match the MDY order of your custom date format.

    Comment


      #3
      Thanks ..after setting the input format it is working perfectly.

      But now i have another problem, now i want to set mask in date field


      ((DateItem)formItem).setInputFormat(Cookies.getCookie("dateFormat"));
      ((DateItem)formItem).setUseMask(true);
      ((DateItem)formItem).setMaskDateSeparator(Cookies.getCookie("dateSeperator"));


      here depening upon locale i am setting "dateSeperator" and "dateFormat" cookie value, and excuting same code for DateUtils also.
      Now when my locale is gemany[de]

      date seperator "."
      date format i am setting "dd.MM.yyyy"

      in this case masking creating problem when i am setting a date from picker more than 20. The value comming in text box is worng

      Comment


        #4
        What do you mean by setting the "more than 20"?

        Comment


          #5
          if i choose day more >20 like
          20th jun 2011 or 21th june 2011 ...etc from picker...
          its automatically converting to 0.06.2011 or 1.06.2011 ...etc

          Comment


            #6
            Thats definitely not happening for anyone else. If it were happening when the day is more than 12 it would mean that your input format is still reversed (day and month swpped).

            If you think there's a bug, include all the details mentioned in the FAQ, including a minimal runnable test case, as well as the timezone you're testing in and exact date value tested.

            Comment

            Working...
            X