I have a function that must work the same way on both client and server and it formats dates.
if (GWT.isClient())
{
// Use DateTimeFormat
} else {
// Use SimpleDateFormat
}
GWT complains: No source code is available for type SimpleDateFormat. The error is not fatal (at least in dev mode), but annoying and no way to suppress it. Found a similar question on http://groups.google.com/group/google-web-toolkit/browse_thread/thread/981247fca161c287 . There they suggest:
You can provide a dummy supersource implementation of SimpleDateTimeFormat so that it would compile.
I tried. Now Eclipse complains:
java.text The declared package "java.text" does not match the expected package "foo.jre.java.text" SimpleDateFormat.java
You have to tell Eclipse not to compile your super-source'd Java file. If you're using Maven, it's simply a matter of moving it to src/main/resources; otherwise, exclude your 'jre' package from Eclipse's build path.
...that being said, I'd rather super-source the class the uses the SimpleDateFormat/DateTimeFormat, and/or move that to a helper class that you'd super-source.