2

I'm working on an existing GWT app . I'm seeing this warning

the constructor Date(int, int, int) is deprecated

Since java.util.Calendar is not supported in GWT client side , I'm looking for how to replace this methode .

Yuri
  • 447
  • 3
  • 9
  • 19
  • If you can use Java 8, [this reference](http://www.oracle.com/technetwork/articles/java/jf14-date-time-2125367.html) has some examples. – SME_Dev Sep 22 '15 at 15:38

3 Answers3

6

There's no replacement for GWT (for now at least, java.time support/emulation should come some time in the future). Just put @SuppressWarnings("deprecation") if you want to get rid of the warning.

Thomas Broyer
  • 64,353
  • 7
  • 91
  • 164
-2

I believe this will help answer your question.

You can use the Calendar.set() and Calendar.get() methods to set/get the date.

Community
  • 1
  • 1
Peter Huffer
  • 259
  • 2
  • 5
  • Welcome to Stack Overflow! Whilst this may theoretically answer the question, [it would be preferable](//meta.stackoverflow.com/q/8259) to include the essential parts of the answer here, and provide the link for reference. – Jérémie Bertrand Sep 22 '15 at 15:44
  • 2
    Unfortunately, `Calendar` is not available in the [subset of JRE](http://www.gwtproject.org/doc/latest/RefJreEmulation.html) that GWT supports on the client side. – Igor Klimer Sep 22 '15 at 21:57
-2

Use always Calendar (GregorianCalendar would suit what you need). And when you need to turn it into a Date object, use Calendar.getTime()

This page has examples: http://www.mkyong.com/java/java-date-and-calendar-examples/

fmcato
  • 172
  • 1
  • 12
  • The question stated that Calendar is not supported by GWT, which uses a subset of the Java language. – Kyle A Jun 10 '20 at 15:24