PDA

View Full Version : DateTimeFormat issue



jamone
5 Jan 2012, 3:18 AM
I have a DateField and the datefield renders as "yyyy-mm-dd" for example: 2012-01-05, I wish to retrieve the DateField value but I get "2012-00-05", January is apparently set to month number 0, how can I get the displayed value for the DateField?

Relevant bits of code:

invoiceDate = new DateField();
invoiceDate.setFieldLabel("Invoice Date");
::::::::::::::::::::::::::::::::::
if (null != invoiceLine.getValue()) {
searchData.setInvoiceLine(invoiceLine.getValue());
}
:::::::::::::::::::::::::::::::::::
DateTimeFormat fmt = DateTimeFormat.getFormat("yyyy-mm-dd");
:::::::::::::::::::::::::::::::::::
if (null != searchData.getInvoiceDate()) {
System.out.println(fmt.format(searchData.getInvoiceDate()));
}
::::::::::::::::::::::::::::::::::

without the format I get: Thu Jan 05 12:00:00 ICT 2012
with the format I get: 2012-00-05

Why does anyone represent the months of the year as 00-11?

Has anyone else encountered this? How do you solve it?

Thanks in advance.
Cheers.

sven
5 Jan 2012, 3:26 AM
Have you looked at the javadoc for the class you are using (which is not even related to GXT)?

http://google-web-toolkit.googlecode.com/svn/javadoc/2.4/com/google/gwt/i18n/client/DateTimeFormat.html


(http://google-web-toolkit.googlecode.com/svn/javadoc/2.4/com/google/gwt/i18n/client/DateTimeFormat.html)m is relevant for the minutes, you are looking for M

jamone
5 Jan 2012, 8:06 PM
I spotted that 5 minutes after I sent this thread. Sorry coding at 3AM.

Cheers.