PDA

View Full Version : GXT Date Format display issue



samad.atoro
27 Sep 2013, 12:11 PM
Hello All. I updated GWT from 2.0.3 to 2.5.0 and GXT from 2.2.0 to 2.2.5. The date is set to display in long format. used to be September 27, 2013. But it now displays as 2013 September 2013. Any idea on where I can fix this? Thanks

branflake2267
27 Sep 2013, 12:26 PM
Will this work or could you provide a sample of the code you are using to setup the format?



theDate.setFormat(DateTimeFormat.getFormat(PredefinedFormat.DATE_LONG));

samad.atoro
27 Sep 2013, 1:54 PM
The code was

String dateStr = DateTimeFormat.getLongDateFormat().format(date);
Since the getLongDateFormat() method is now deprecated, I changed it to

String dateStr = DateTimeFormat.getFormat(PredefinedFormat.DATE_LONG).format(currentlySelectedDate);


But today's date still shows as 2013 September 27.
Thanks

Colin Alworth
27 Sep 2013, 2:25 PM
Samad.atoro, it looks as though the code changed slightly in terms of how locales work between 2.0 and current. The "default" locale uses "y MMMM d" for DATE_LONG, while "en" uses "MMMM d, y" which is what I think you are after. Can you confirm which locale you have configured?

samad.atoro
27 Sep 2013, 2:40 PM
I will have to specify the format myself using "MMMM dd, yyyy"

Thanks

samad.atoro
27 Sep 2013, 2:44 PM
The default locale is en_US. I tried to manually specify the locale in the my .gwt.xml, but it complained about a reconfiguration of the locale. So looks like I could specify the locale to "en" and it will work? I will try.

Colin Alworth
27 Sep 2013, 3:10 PM
Yes, specifying "en" should kick it to using the format string you are after (along with some changes to number that make it specific to the US anyway). There isn't a en_US as you've noticed, but instead en seems to be US specific.

samad.atoro
28 Sep 2013, 7:09 AM
Colin, Thanks for your help. I inherited this code. So I'm having to read online articles and diging through the code to make sense of everything.

I see this line in the home html page where the map is loaded.


<meta name="gwt:property" id="localeProperty" content="locale=en_US">

I changed it to
<meta name="gwt:property" id="localeProperty" content="locale=en">

I believe that it's expecting xx_YY format.

I gave up on it for now and manually specified the format that I needed in the code. I will come back to this later as I'm facing a new issue. I just posted a new issue about my map displaying with the minimum size inside a ContentWidget panel. I will keep you posted once I figured out the locale issue. Thanks a lot
I ended up