Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use java.util.Calendar in GWT

Tags:

I have to use java.util.Calendar in GWT entry point, but I got error while running the application, that is because GWT is not able to find source code, is there anyway I could fix this issue.

Thanks in advance!!!

like image 892
Delli Kilari Avatar asked Aug 10 '11 10:08

Delli Kilari


People also ask

What is Java Util calendar?

The java.util.calendar class is an abstract class that provides methods for converting between a specific instant in time and a set of calendar fields such as YEAR, MONTH, DAY_OF_MONTH, HOUR, and so on, and for manipulating the calendar fields, such as getting the date of the next week.Following are the important ...


1 Answers

java.util.Calendar is not an emulated class. You can find a list of emulated classes here:

http://code.google.com/webtoolkit/doc/latest/RefJreEmulation.html

I would strongly advise not to use any date/calendar library on the client side. You will probably only get yourself into trouble. In fact, even though java.sql.Date and java.util.Date are emulated in GWT, I would not use these either. If you're looking to use Calendar, then chances are you want to support timezones on the client. Using the emulated Date classes, you will somehow have to convert the client's Date from the browser's timezone to some target timezone (GMT or whatever the user defined in user preferences?). This will most definitely be error prone. Using GWT's TimeZone adds other issues. For instance, how do you map between java TimeZones and GWT TimeZones?

I recommend doing all date manipulation AND formatting on the server. On the client, you can simply use a date/month/year triplet. The server can have an association between user (or organization) and java.util.TimeZone (or joda timezone). Using the triplet and timezone you can easily create the specific instance in time.

like image 170
nogridbag Avatar answered Oct 11 '22 06:10

nogridbag