About Date object in GWT

331 views
Skip to first unread message

Sabbir

unread,
May 14, 2010, 9:13:28 PM5/14/10
to Google Web Toolkit
the methods in Date objecat as getTime, getHour, etc are deprecated
ones.
And in GWT calendar object is not allowed.

so how do set the date object in GWT???

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

Jim Douglas

unread,
May 14, 2010, 10:00:47 PM5/14/10
to Google Web Toolkit
Just use java.util.Date; ignore the deprecation warnings.

rjcarr

unread,
May 15, 2010, 6:07:17 AM5/15/10
to Google Web Toolkit
What Jim said, or: com.google.gwt.i18n.client.DateTimeFormat

Sabbir

unread,
May 17, 2010, 2:50:17 AM5/17/10
to Google Web Toolkit
and how about reading the years, months, day, hour, minutes and
seconds from the date object?



On May 15, 6:13 am, Sabbir <leo.sh...@gmail.com> wrote:
> the methods inDateobjecat as getTime, getHour, etc are deprecated
> ones.
> And in GWT calendarobjectis not allowed.
>
> so how do set thedateobjectin GWT???

aditya sanas

unread,
May 17, 2010, 2:57:33 AM5/17/10
to google-we...@googlegroups.com
Ignore deprecation warning 
u have only one option on client side i.e. Date() object from java.util
so user getYear(),getMonth() etc. methods for getting hrs minutes secs and year 
--
Aditya

euzuro

unread,
May 18, 2010, 1:00:36 PM5/18/10
to Google Web Toolkit
If you look at some of the files in the
com.google.gwt.user.datepicker.client[1], you'll see that the gwt
developers themselves are freely using these deprecated java.util.Date
methods.

To avoid the java warnings, they put a @SuppressWarnings() at the head
of any method that uses them (or sometimes the entire class)
@SuppressWarnings(/* Required to use Date API in gwt */
{"deprecation"})


I think the argument here is that the GWT implementation of
java.util.Date is based on the JavaScript Date object, and therefore
it's OK to use those methods.

You still have to be wary of timezone issues, though. For example:

Date today = new Date();
Window.alert(today.getHour());

...will show different values if you are in Amsterdam or in Mexico
City.

Erik


[1] http://google-web-toolkit.googlecode.com/svn/trunk/user/src/com/google/gwt/user/datepicker/client/

On May 17, 1:57 am, aditya sanas <007aditya.b...@gmail.com> wrote:
> Ignore deprecation warning
> u have only one option on client side i.e. Date() object from java.util
> so user getYear(),getMonth() etc. methods for getting hrs minutes secs and
> year
> --
> Aditya
>
>
>
> On Mon, May 17, 2010 at 12:20 PM, Sabbir <leo.sh...@gmail.com> wrote:
> > and how about reading the years, months, day, hour, minutes and
> > seconds from the date object?
>
> > On May 15, 6:13 am, Sabbir <leo.sh...@gmail.com> wrote:
> > > the methods inDateobjecat as getTime, getHour, etc are deprecated
> > > ones.
> > > And in GWT calendarobjectis not allowed.
>
> > > so how do set thedateobjectin GWT???
>
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > "Google Web Toolkit" group.
> > > To post to this group, send email to google-we...@googlegroups.com
> > .
> > > To unsubscribe from this group, send email to
> > google-web-tool...@googlegroups.com<google-web-toolkit%2Bunsu...@googlegroups.com>
> > .
> > > For more options, visit this group athttp://
> > groups.google.com/group/google-web-toolkit?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Google Web Toolkit" group.
> > To post to this group, send email to google-we...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > google-web-tool...@googlegroups.com<google-web-toolkit%2Bunsu...@googlegroups.com>
> > .

euzuro

unread,
May 17, 2010, 12:33:07 PM5/17/10
to Google Web Toolkit
Apologies if this message is duplicated... I thought I sent it earlier
this morning but it seems to have not gone through for some reason


If you look at the code in the com.google.gwt.user.datepicker.client
package, you'll see that the gwt developers themselves
use these deprecated Date methods throughout their code.

They suppress the warnings using:
@SuppressWarnings(/* Required to use Date API in gwt */
{"deprecation"})

....which to me is a green light to use it yourself if I've ever seen
one.


I think the idea is that since the gwt implementation of
java.util.Date is based on the
JavaScript Date object, it actually is OK to use them.

Of course, you still have to be wary of timezones:

Date today = new Date();
Window.alert(today.getHour());

...will output different values in Tokio than in Chicago.


On May 17, 1:57 am, aditya sanas <007aditya.b...@gmail.com> wrote:
> Ignore deprecation warning
> u have only one option on client side i.e. Date() object from java.util
> so user getYear(),getMonth() etc. methods for getting hrs minutes secs and
> year
> --
> Aditya
>
>
>
> On Mon, May 17, 2010 at 12:20 PM, Sabbir <leo.sh...@gmail.com> wrote:
> > and how about reading the years, months, day, hour, minutes and
> > seconds from the date object?
>
> > On May 15, 6:13 am, Sabbir <leo.sh...@gmail.com> wrote:
> > > the methods inDateobjecat as getTime, getHour, etc are deprecated
> > > ones.
> > > And in GWT calendarobjectis not allowed.
>
> > > so how do set thedateobjectin GWT???
>
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > "Google Web Toolkit" group.
> > > To post to this group, send email to google-we...@googlegroups.com
> > .
> > > To unsubscribe from this group, send email to
> > google-web-tool...@googlegroups.com<google-web-toolkit%2Bunsu...@googlegroups.com>
> > .
> > > For more options, visit this group athttp://
> > groups.google.com/group/google-web-toolkit?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Google Web Toolkit" group.
> > To post to this group, send email to google-we...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > google-web-tool...@googlegroups.com<google-web-toolkit%2Bunsu...@googlegroups.com>
> > .

euzuro

unread,
May 17, 2010, 9:35:24 AM5/17/10
to Google Web Toolkit
If you look at the files in the com.google.gwt.user.datepicker.client
package[1],
you can take a tip from the google guys themselves -- they use all
these
deprecated java.util.Date functions all over the place.

Each method that uses them they prefix with:
@SuppressWarnings(/* Required to use Date API in gwt */
{"deprecation"})

to avoid the deprecation warnings.

There was a thread somewhere where one of the actual gwt team members
commented on this. If I remember correctly, the basic point was that
the
gwt implementation of java.util.Date is based on the JavaScript Date
object,
and so using those methods is OK.

the one thing you have to be careful of is timezone sensitivity.

Date today = new Date();
Window.alert(today.getHour());

...for example, will be different in Frankfurt than in New York

[1] http://google-web-toolkit.googlecode.com/svn/trunk/user/src/com/google/gwt/user/datepicker/client/


On May 17, 1:57 am, aditya sanas <007aditya.b...@gmail.com> wrote:
> Ignore deprecation warning
> u have only one option on client side i.e. Date() object from java.util
> so user getYear(),getMonth() etc. methods for getting hrs minutes secs and
> year
> --
> Aditya
>
>
>
> On Mon, May 17, 2010 at 12:20 PM, Sabbir <leo.sh...@gmail.com> wrote:
> > and how about reading the years, months, day, hour, minutes and
> > seconds from the date object?
>
> > On May 15, 6:13 am, Sabbir <leo.sh...@gmail.com> wrote:
> > > the methods inDateobjecat as getTime, getHour, etc are deprecated
> > > ones.
> > > And in GWT calendarobjectis not allowed.
>
> > > so how do set thedateobjectin GWT???
>
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > "Google Web Toolkit" group.
> > > To post to this group, send email to google-we...@googlegroups.com
> > .
> > > To unsubscribe from this group, send email to
> > google-web-tool...@googlegroups.com<google-web-toolkit%2Bunsu...@googlegroups.com>
> > .
> > > For more options, visit this group athttp://
> > groups.google.com/group/google-web-toolkit?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Google Web Toolkit" group.
> > To post to this group, send email to google-we...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > google-web-tool...@googlegroups.com<google-web-toolkit%2Bunsu...@googlegroups.com>
> > .
Reply all
Reply to author
Forward
0 new messages