How to do calendar operations in Java GWT? How to add days to a Date?

Witek picture Witek · Mar 27, 2010 · Viewed 38.2k times · Source

Since GWT does not provide the GregorianCalendar class, how to do calendar operations on the client?

I have a Date a and I want the Date, which is n days after a.

Examples:

a (2000-01-01) + n (1) -> 2000-01-02
a (2000-01-01) + n (31) -> 2000-02-01

Answer

Tony BenBrahim picture Tony BenBrahim · Mar 22, 2011

Updated answer for GWT 2.1

final Date dueDate = new Date();
CalendarUtil.addDaysToDate(dueDate, 21);

Edit: the fully qualified name of this class is com.google.gwt.user.datepicker.client.CalendarUtil.