i use DateItem, i want to display the date in text field as "MM/DD/YY" format, but it is not included in DateDisplayFormat enum, how can i customize the date display format for DateItem??
							
						
					Announcement
				
					Collapse
				
			
		
	
		
			
				No announcement yet.
				
			
				
	
X
- 
	
	
		
		
		
		
		
		
		
	
	
 it seems the DateUtil can help,
 original code:
 it can not display the date as format of "MM/DD/YY". So i change the code to:Code:firstDateChoice = new DateItem(); firstDateChoice.setUseTextField(true); firstDateChoice.setPickerIconSrc(...........); firstDateChoice.setPickerIconWidth(26); firstDateChoice.setPickerIconHeight(26);
 unfortunately, wheather i choose any date, the text field ALWAYS display "08//", while i change to "DateUtil.setNormalDateDisplayFormatter" (regarding to the api document, i can not identify the differences of these two method.), it also does not follow the format i required.Code:DateUtil.setShortDateDisplayFormatter(new DateDisplayFormatter() { public String format(Date date) { if (date == null) { return null; } //you'll probably want to create the DateTimeFormat outside this method. //here for illustration purposes DateTimeFormat dateFormatter = DateTimeFormat.getFormat("MM/DD/YY"); String format = dateFormatter.format(date); return format; } }); firstDateChoice = new DateItem(); firstDateChoice.setUseTextField(true); firstDateChoice.setPickerIconSrc(...........); firstDateChoice.setPickerIconWidth(26); firstDateChoice.setPickerIconHeight(26);
 who can help?
 
- 
	
	
		
		
		
		
		
		
		
	
	
 hi zbc,
 guess i found kind of a solution:
 Here is the code:
 
 I guess the important point is to set "dateFormatter" to "toNormalDate" as mentioned in the documentation.Code:DateUtil.setNormalDateDisplayFormatter(new DateDisplayFormatter() { @Override public String format(Date date) { if (date == null) { return null; } final DateTimeFormat dateFormatter = DateTimeFormat.getFormat("dd.MM.yyyy | HH:mm"); String format = dateFormatter.format(date); return format; } }); DateItem dateItem = new DateItem(); dateItem.setUseTextField(true); dateItem.setAttribute("dateFormatter", "toNormalDate");
 Comment

Comment